home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77709_inc_wsa.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  128.3 KB  |  3,988 lines

  1. <%
  2.         '
  3.         ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  4.         '
  5.     Const CONST_SUCCESS    =    0
  6.     
  7.     'const error codes
  8.     Const CONST_USER_NOTFOUND_ERRMSG        = &H800708AD
  9.     Const CONST_OBJECT_EXISTS_ERRMSG        = &H80071392
  10.     Const CONST_OBJECT_NOTEXISTS_ERRMSG        = &H80072030
  11.     Const CONST_QUOTA_USER_NOTFOUND_ERRMSG    = &H80070002
  12.     Const CONST_LDAP_SERVER_NOTOP            = &H8007203A
  13.     Const CONST_LDAP_SERVER_NOTEXIST        = &H8007200A
  14.     Const CONST_DOMAINROLE_ERROR            = &H10
  15.     Const wbemErrNotFound                   = &H80041002
  16.  
  17.     Const WBEMFLAG = 131072
  18.  
  19.     Const CONST_SITE_STARTED    = &H2
  20.     Const CONST_SITE_STOPPED    = &H4
  21.     Const CONST_SITE_PAUSED        = &H6
  22.  
  23.     'file perm constants
  24.     Const CONST_FULLCONROL    = &H1F01FF
  25.     Const CONST_MODIFYDELTE    = &H1301BF
  26.     Const CONST_READEXEC    = &H1200A9
  27.  
  28.     ' From ntioapi.h
  29.     ' #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ     |\
  30.     '                            FILE_READ_DATA           |\
  31.     '                            FILE_READ_ATTRIBUTES     |\
  32.     '                            FILE_READ_EA             |\
  33.     '                            SYNCHRONIZE)
  34.     Const FILE_GENERIC_READ = &H120089
  35.  
  36.     'sid string constants
  37.     
  38.     ' From ntseapi.h
  39.     '//     Interactive             S-1-5-4
  40.     Const SIDSTRING_INTERACTIVE = "S-1-5-4"
  41.  
  42.  
  43.     'reg constants
  44.     Const CONST_WEBBLADES_REGKEY    = "Software\Microsoft\ServerAppliance"
  45.     Const CONST_WEBSITEROOT_REGVAL    = "WebSiteRoot"
  46.     Const CONST_FTPSITEROOT_REGVAL    = "FtpRoot"
  47.     Const CONST_FPSEOPTION_REGVAL    = "FPSEOption"
  48.     Const CONST_FTPSITEID_REGVAL    = "AdminFTPServerName"
  49.  
  50.     'website root and ftp site root constants
  51.     Const CONST_DEF_WEBROOT            = "Websites"
  52.     Const CONST_DEF_FTPROOT            = "Web Site Content FTP root"
  53.     Const CONST_QUOTASTATE            = "Unable to create directory"
  54.     Const CONST_FRONTPAGE_PATH        = "W3SVC/Filters/fpexedll.dll"    
  55.     Const CONST_FRONTPAGE_2002_INSTALLED = "Setup Packages"
  56.     Const CONST_SHAREPOINT_INSTALLED = "SharePoint"
  57.  
  58.     'security permission constants
  59.     Const ADS_RIGHT_GENERIC_READ                    = &H80000000
  60.     Const ADS_RIGHT_GENERIC_ALL                        = &H10000000
  61.  
  62.     Const ADS_RIGHT_DS_CREATE_CHILD                    = &H1
  63.     Const ADS_RIGHT_DS_DELETE_CHILD                    = &H2
  64.  
  65.     Const ADS_ACETYPE_ACCESS_ALLOWED                = 0
  66.     Const ADS_ACETYPE_ACCESS_ALLOWED_OBJECT            = &H5
  67.  
  68.     Const ADS_FLAG_OBJECT_TYPE_PRESENT                = &H1
  69.     Const ADS_FLAG_INHERITED_OBJECT_TYPE_PRESENT    = &H2
  70.     Const ADS_ACEFLAG_INHERIT_ACE = &H2
  71.     Const ADS_ACEFLAG_INHERIT_ONLY_ACE                = &H8
  72.  
  73.     'A list of the various object GUIDs
  74.     Const USERGUID        = "{BF967ABA-0DE6-11D0-A285-00AA003049E2}"
  75.     Const GROUPGUID        = "{bf967a9c-0de6-11d0-a285-00aa003049e2}"
  76.     Const OUGUID        = "{bf967aa5-0de6-11d0-a285-00aa003049e2}"
  77.  
  78.     'Error constants for CreateSitePath function
  79.     Const CONST_CREATE_FSOBJ_FAILED        =    &H100
  80.     Const CONST_INVALID_DRIVE            =    &H101
  81.     Const CONST_NOTNTFS_DRIVE            =    &H102
  82.     Const CONST_FAILED_TOCREATE_DIR        =    &H103
  83.  
  84.     ' Front Page related constants
  85.     Const CONST_FRONTPAGE_REGLOC = "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\4.0"
  86.     Const CONST_FRONTPAGE_2002_REGLOC = "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\5.0"
  87.     Const CONST_PORT_REGLOC = "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\Ports\"
  88.     Const CONST_NOLIMIT_TEXT            = "No limit"    
  89.     
  90.     'Domain Role
  91.     Const MEMBER_ADDC                        = 0
  92.     Const MEMBER_NTDC                        = 1
  93.     Const WORKSTATION                        = 1
  94.     Const MEMBER_WORKGROUP                   = 2
  95.     Const MEMBER_DOMAIN                      = 3
  96.     Const BACKUP_DOMAIN_CONTROLLER           = 4
  97.     Const PRIMARY_DOMAIN_CONTROLLER          = 5
  98.     Const DOMAIN_CONTROLLER                  = 6
  99.     
  100.     'Add for globalization of Web/FTP log settings
  101.     Const CONST_MSIISLOGFILE_FORMAT = "Microsoft IIS Log File Format"
  102.     Const CONST_NCSALOGFILE_FORMAT  = "NCSA Common Log File Format"
  103.     Const CONST_ODBCLOGFILE_FORMAT  = "ODBC Logging"
  104.     Const CONST_W3CEXLOGFILE_FORMAT = "W3C Extended Log File Format"
  105.     
  106.     'Running state of the service
  107.     Const CONST_SERVICE_RUNNING_STATE = "Running"
  108.     
  109.     'Running state of FTP server (serverstate = 2, started)
  110.     Const CONST_FTPSERVER_RUNNING_STATE = 2
  111.     'Stopped state of FTP server (serverstate = 4, stopped)
  112.     Const CONST_FTPSERVER_STOPPED_STATE = 4
  113.     
  114.     Dim sReturnURL            ' to hold return URL    
  115.     sReturnURL = "../tasks.asp"    
  116.     Call SA_MungeURL(sReturnURL, "Tab1", "TabsWelcome")
  117.     
  118.     ' GUID constants for the four IIS logging plug-ins.  These GUIDs have been
  119.     ' verified with the IIS WMI providers on both Win2K and .Net.
  120.     Const CONST_MSIISLOGFILE_GUID    = "{FF160657-DE82-11CF-BC0A-00AA006111E0}"
  121.     Const CONST_NCSALOGFILE_GUID    = "{FF16065F-DE82-11CF-BC0A-00AA006111E0}"
  122.     Const CONST_ODBCLOGFILE_GUID    = "{FF16065B-DE82-11CF-BC0A-00AA006111E0}"
  123.     Const CONST_W3CEXLOGFILE_GUID    = "{FF160663-DE82-11CF-BC0A-00AA006111E0}"
  124.     
  125.     '
  126.     ' Upload method constants for application settings tab.
  127.     Const UPLOADMETHOD_NEITHER  = "0"
  128.     Const UPLOADMETHOD_FPSE     = "1"
  129.     Const UPLOADMETHOD_FTP      = "2"
  130.     
  131.  
  132.     '-------------------------------------------------------------------------
  133.     'Function name:        IISLogFileGUIDToENName
  134.     'Description:        Converts the given IIS Log File Plug-in GUID into
  135.     '                    the English-US name for that plug-in as
  136.     '                    long as the GUID is one of the four we recognize.
  137.     'Input Variables:    strGUID    - The plug-in GUID.
  138.     'Returns:            The US English name of the plug-in or an
  139.     '                    empty string if the GUID is unrecognized.
  140.     'Global Variables:    None
  141.     '-------------------------------------------------------------------------
  142.     Function IISLogFileGUIDToENName(strGUID)
  143.         Select Case strGUID
  144.             Case CONST_MSIISLOGFILE_GUID
  145.                 IISLogFileGUIDToENName = CONST_MSIISLOGFILE_FORMAT
  146.             Case CONST_NCSALOGFILE_GUID
  147.                 IISLogFileGUIDToENName = CONST_NCSALOGFILE_FORMAT
  148.             Case CONST_ODBCLOGFILE_GUID
  149.                 IISLogFileGUIDToENName = CONST_ODBCLOGFILE_FORMAT
  150.             Case CONST_W3CEXLOGFILE_GUID
  151.                 IISLogFileGUIDToENName = CONST_W3CEXLOGFILE_FORMAT
  152.             Case Else
  153.                 IISLogFileGUIDToENName = ""
  154.         End Select
  155.     End Function
  156.  
  157.     '-------------------------------------------------------------------------
  158.     'Function name:        IISLogFileENNameToGUID
  159.     'Description:        Converts the given IIS Log File Plug-in US
  160.     '                    English name into the GUID for that plug-in as
  161.     '                    long as the name is one of the four we recognize.
  162.     'Input Variables:    strName    - The US English plug-in name.
  163.     'Returns:            The GUID of the plug-in or an empty string
  164.     '                    if the name is unrecognized.
  165.     'Global Variables:    None
  166.     '-------------------------------------------------------------------------
  167.     Function IISLogFileENNameToGUID(strName)
  168.         Select Case strName
  169.             Case CONST_MSIISLOGFILE_FORMAT
  170.                 IISLogFileENNameToGUID = CONST_MSIISLOGFILE_GUID
  171.             Case CONST_NCSALOGFILE_FORMAT
  172.                 IISLogFileENNameToGUID = CONST_NCSALOGFILE_GUID
  173.             Case CONST_ODBCLOGFILE_FORMAT
  174.                 IISLogFileENNameToGUID = CONST_ODBCLOGFILE_GUID
  175.             Case CONST_W3CEXLOGFILE_FORMAT
  176.                 IISLogFileENNameToGUID = CONST_W3CEXLOGFILE_GUID
  177.             Case Else
  178.                 IISLogFileENNameToGUID = ""
  179.         End Select
  180.     End Function
  181.  
  182.     '-------------------------------------------------------------------------
  183.     'Function name:        CreateOU
  184.     'Description:        Creates the ou under specified parent ou
  185.     'Input Variables:    strOuName - ou name
  186.     '                    objParent - parent of ou to be created
  187.     'Output Variables:    objOu - created ou
  188.     'Returns:            returns Error Message
  189.     'Global Variables:    None
  190.     '-------------------------------------------------------------------------
  191.     Function CreateOU(strOuName, strDesc, objRoot, ByRef objOu)
  192.         On Error Resume Next
  193.         Err.clear
  194.         
  195.         Set objOu = objRoot.Create("organizationalUnit", "ou=" & strOuName)
  196.         objOu.Put "Description", strDesc
  197.         objOu.SetInfo
  198.         
  199.         CreateOU = err.number
  200.     End Function
  201.  
  202.     '-------------------------------------------------------------------------
  203.     'Function name:        getObjSiteCollection
  204.     'Description:        Returns an Instance of IIs_WebServerSetting
  205.     'Input Variables:    None
  206.     'Output Variables:    
  207.     'Returns:            Object        -Returns an object 
  208.     'Global Variables:    None
  209.     'If object fails dislays the error message
  210.     '-------------------------------------------------------------------------
  211.     Function getObjSiteCollection(objService) 
  212.         Err.Clear 
  213.         On Error Resume Next
  214.  
  215.         Dim siteCollection        'holds sitecollection
  216.         Dim strQuery            'holds query string    
  217.         
  218.         'form the query
  219.         strQuery = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting")
  220.         
  221.         Set siteCollection = objService.ExecQuery(strQuery)
  222.  
  223.         If Err.number   <>  0 Then 
  224.             SA_ServeFailurepageEx L_INFORMATION_ERRORMESSAGE, sReturnURL
  225.             getObjSiteCollection = false
  226.             exit function
  227.         End If  
  228.  
  229.         Set getObjSiteCollection = siteCollection
  230.  
  231.      End function
  232.  
  233.     '-------------------------------------------------------------------------
  234.     'Function name:        CreateManagedSiteRegKey
  235.     'Description:        Creates the reg key for this site under SOFTWARE\
  236.     '                    Microsoft\WebServerAppliance\ManagedWebSites
  237.     'Input Variables:    nSiteNo, strSiteID
  238.     'Output Variables:    
  239.     'Returns:        None
  240.     'Global Variables:    None
  241.     '-------------------------------------------------------------------------
  242.     Function MakeManagedSite(objService, strSiteNum,servercomment)
  243.         On Error Resume Next
  244.         Err.Clear 
  245.         
  246.         Dim strObjPath        'holds object path
  247.         Dim objVirDir        'holds virtualdirectory collection
  248.  
  249.         MakeManagedSite =  false
  250.         
  251.         'set ServerID     
  252.         strObjPath = GetIISWMIProviderClassName("IIs_WebServerSetting") & ".Name=" & chr(34) & strSiteNum & chr(34)        
  253.         
  254.         set objVirDir = objService.Get( strObjPath )
  255.         
  256.         If Err.number <> 0 Then
  257.             SA_TraceOut "inc_wsa", "get vir dir object failed " & Hex(Err.Number)
  258.             exit Function
  259.         End if
  260.         
  261.         'call the method to set serverID property
  262.         objVirDir.serverID = servercomment
  263.         
  264.         objVirDir.put_(WBEMFLAG)
  265.  
  266.         if Err.number <> 0 then            
  267.             SA_TraceOut "Make Managed Site",  "Failed to set ServerID" & "(" & Hex(Err.Number) & ")"
  268.             Set objVirDir = nothing
  269.             exit function
  270.         end if
  271.         MakeManagedSite =  true
  272.         
  273.         Set objVirDir = nothing
  274.     End Function
  275.      
  276.      
  277.     '-------------------------------------------------------------------------
  278.     'Function name        :isValidSiteIdentifier
  279.     'Description        :Returns an Instance of IIs_WebServerSetting
  280.     'Input Variables    :None
  281.     'Output Variables    :None    
  282.     'Returns            :Object        -Returns an object 
  283.     'Global Variables    :None
  284.     'If object fails dislays the error message
  285.     '-------------------------------------------------------------------------
  286.     Function isValidSiteIdentifier(strSiteID, _
  287.                                 strAdminName, _
  288.                                 strDirRoot, _
  289.                                 bVerifyUser)
  290.         Err.Clear 
  291.         On Error Resume Next            
  292.  
  293.         isValidSiteIdentifier = FALSE
  294.  
  295.         'verify the siteid
  296.         If CStr(GetWebSiteNo(strSiteID)) <> "" Then
  297.             SA_TraceOut "inc_wsa", "Failed: isValidSiteIdentifier"
  298.             Exit Function
  299.         End If
  300.  
  301.         'verify the administrator
  302.         If bVerifyUser Then
  303.             If isValidUser(strAdminName, strDirRoot) = FALSE Then
  304.                 SA_TraceOut "inc_wsa", "Failed: isValidSiteIdentifier"
  305.                 Exit Function
  306.             End If
  307.         End If
  308.  
  309.         isValidSiteIdentifier = TRUE
  310.         SA_TraceOut "inc_wsa", "success isValidSiteIdentifier"
  311.      End function
  312.      
  313.      
  314.     '-------------------------------------------------------------------------
  315.     'Function name        :isValidUser
  316.     'Description        :Returns an Instance of IIs_WebServerSetting
  317.     'Input Variables    :None
  318.     'Output Variables    :    
  319.     'Returns            :Object        -Returns an object 
  320.     'Global Variables    :None
  321.     'If object fails dislays the error message
  322.     '-------------------------------------------------------------------------
  323.     Function isValidUser(strUserName, strDirRoot)
  324.         On Error Resume Next
  325.         Err.Clear
  326.         
  327.         Dim objComputer        'holds Computer object
  328.         Dim objUser
  329.  
  330.         isValidUser = False
  331.         Set objComputer = GetObject("WinNT://" & strDirRoot)
  332.         Set objUser = objComputer.GetObject("User",strUserName)
  333.  
  334.         If Err.number <> 0 Then
  335.             isValidUser = True
  336.             Set objComputer = nothing
  337.             Exit Function
  338.         End If
  339.  
  340.         Set objComputer = nothing
  341.         Set objUser = nothing
  342.      End function
  343.  
  344.  
  345.     '-------------------------------------------------------------------------
  346.     'Function name        :GetNewSiteNo
  347.     'Description        :Returns an Free Site no
  348.     'Input Variables    :None
  349.     'Output Variables    :    
  350.     'Returns            :siteno
  351.     'Global Variables    :None
  352.     'If object fails dislays the error message
  353.     '-------------------------------------------------------------------------
  354.     Function GetNewSiteNo()
  355.         On Error Resume Next
  356.         Err.Clear 
  357.         
  358.         Dim  objService        'holds WMI Connection        
  359.         Dim     objInstances    'holds WebServer Instance
  360.         Dim  objInstance    'holds instance object
  361.         Dim  nSiteNo        'holds sitenumber value
  362.         Dim  nPos            'holds position value
  363.         Dim  nCount            'holds count value
  364.         Dim  index            'holds index value
  365.         Dim  nStart            'holds start value
  366.         Dim  bFound            'holds boolean value
  367.         Dim arrSiteNo        'holsd arraysite number
  368.  
  369.         GetNewSiteNo = -1
  370.         
  371.         Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  372.         Set objInstances = objService.InstancesOf(GetIISWMIProviderClassName("IIS_WebServer"))
  373.  
  374.         nCount = objInstances.Count
  375.  
  376.         'store the existing site no. in the array
  377.         ReDim arrSiteNo(nCount)
  378.         
  379.         For Each objInstance In objInstances
  380.             nPos = InStr(objInstance.Name, "/")
  381.             arrSiteNo(nStart) = Right(objInstance.Name, len(objInstance.Name) - nPos)
  382.             nStart = nStart + 1
  383.         Next
  384.  
  385.         nCount = Ubound(arrSiteNo) - 1
  386.         nSiteNo = 1
  387.         bFound = FALSE
  388.         Do While bFound <> TRUE
  389.             For index= 0 to nCount
  390.                 If Clng(nSiteNo) = Clng(arrSiteNo(index)) Then
  391.                     Exit For
  392.                 End If
  393.             Next
  394.  
  395.             If index > nCount  Then
  396.                 bFound = TRUE
  397.             Else
  398.                 nSiteNo = nSiteNo + 1
  399.             End If
  400.         Loop
  401.  
  402.         SA_TraceOut "inc_wsa", "SiteNo=" & nSiteNo
  403.  
  404.         GetNewSiteNo  = nSiteNo
  405.         Set objService = nothing
  406.         Set objInstances = nothing
  407.     End function
  408.     
  409.  
  410.     '-------------------------------------------------------------------------
  411.     'Sub name            :GetDomainRole
  412.     'Description        :Returns domain and server name of local machine
  413.     'Input Variables    :None
  414.     'Output Variables    :strDirectoryRoot, strSysName    
  415.     'Returns            :None
  416.     'Global Variables    :None
  417.     '-------------------------------------------------------------------------    
  418.     Sub GetDomainRole(ByRef strDirectoryRoot, ByRef strSysName)
  419.         On Error Resume Next
  420.         Err.Clear 
  421.  
  422.         Dim strDomainName        'holds Domain name
  423.         Dim Query                'holds query string
  424.         Dim objService            'holds WMI connection     
  425.         Dim Parent                'holds result query
  426.         Dim role                'holds role of the sytem    
  427.         Dim Domain                'holds domain name
  428.         Dim inst                'holds instance of computer object
  429.  
  430.         strDomainName = ""
  431.         strSysName = ""
  432.         
  433.         Query = "Select * from Win32_ComputerSystem"    
  434.         Set objService = getWMIConnection("root\cimv2")        
  435.     
  436.         set Parent = objService.ExecQuery(Query)        
  437.         If Err.number <> 0 Then    
  438.             SA_TraceOut "Failed to get connection to Computer name space" 
  439.             Exit Sub
  440.         End if
  441.     
  442.         For each inst in Parent
  443.             role = inst.DomainRole
  444.             strDomainName  = inst.Domain    
  445.             strSysName = inst.Name
  446.             exit for
  447.         next 
  448.  
  449.         If (role = MEMBER_DOMAIN) Then     
  450.             strDirectoryRoot = strDomainName
  451.         ElseIf (role = MEMBER_WORKGROUP) Then 
  452.             strDirectoryRoot = strSysName
  453.         End If
  454.     End Sub
  455.  
  456.     '-------------------------------------------------------------------------
  457.     'Function name:            GetWebSiteNo
  458.     'Description:            gets the web site no
  459.     'Input Variables:        strSiteId  - site identifier
  460.     '                        strSysName - system name
  461.     'Returns:                strSiteNo
  462.     '--------------------------------------------------------------------------
  463.     Function GetWebSiteNo(strSiteId)
  464.         On Error Resume Next
  465.         Err.Clear         
  466.         
  467.         Dim Parent            'holds result collection
  468.         Dim Query            'holds query string
  469.         Dim inst            'holds instance or result collection    
  470.         Dim strSiteNo        'holds site name    
  471.         Dim objService        'holds WMI Connection object    
  472.         
  473.         Query = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where ServerID=" & chr(34) & strSiteId & chr(34)
  474.         
  475.         Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)        
  476.         Set Parent = objService.ExecQuery(Query)        
  477.         If Err.number <> 0 Then    
  478.             SA_TraceOut "Failed to get the IIs_WebServerSetting object with error " & "(" & Hex(Err.Number) & ")" 
  479.             exit Function
  480.         End if
  481.         
  482.         For Each inst In Parent
  483.             strSiteNo = inst.Name
  484.             Exit For
  485.         Next                    
  486.                     
  487.         GetWebSiteNo = strSiteNo
  488.         
  489.         Set Parent = nothing        
  490.         Set objService = nothing
  491.     End Function
  492.     
  493.     '-------------------------------------------------------------------------
  494.     'Function name:            GetWebSiteName
  495.     'Description:            gets the web site no
  496.     'Input Variables:        strSiteId  - site identifier                            
  497.     'Returns:                strSiteNo
  498.     '--------------------------------------------------------------------------
  499.     Function GetWebSiteName(strSiteId)
  500.         On Error Resume Next
  501.         Err.Clear 
  502.         
  503.         Dim Parent        'holds result query
  504.         Dim Query        'holds query string    
  505.         Dim inst        'holds instance of Parent
  506.         Dim strSiteName    'holds sitename
  507.         Dim objService    'holds WMI Connection object
  508.         
  509.         Query = GetIISWMIProviderClassName("IIs_WebServerSetting") & ".Name=" & chr(34) & strSiteId & chr(34)
  510.         
  511.         Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)        
  512.         Set Parent = objService.Get( Query )
  513.         
  514.         If Err.number <> 0 Then    
  515.             SA_TraceOut "Failed to get the IIs_WebServerSetting object with error " & "(" & Hex(Err.Number) & ")" 
  516.             exit Function
  517.         End if        
  518.         
  519.         strSiteName = Parent.ServerComment
  520.         
  521.         GetWebSiteName = strSiteName
  522.         
  523.         'Release objects
  524.         Set Parent = nothing
  525.         Set objService = nothing
  526.     End Function
  527.  
  528.     '-------------------------------------------------------------------------
  529.     'Function name:            SetApplProt
  530.     'Description:            Sets Application Protection level
  531.     'Input Variables:        objService, strSiteNum, strProtect
  532.     'Returns:                boolean
  533.     '--------------------------------------------------------------------------
  534.     Function SetApplProt( objService, strSiteNum, strProtect )
  535.         On Error Resume Next
  536.         Err.Clear 
  537.  
  538.         Dim strObjPath        'holds Query string
  539.         Dim objVirDir        'holds query result    
  540.  
  541.         SetApplProt = FALSE
  542.  
  543.         'set application protection
  544.         strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDir") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)
  545.         
  546.         set objVirDir = objService.Get( strObjPath )
  547.         
  548.         If Err.number <> 0 Then
  549.             SA_TraceOut "inc_wsa", "get vir dir object failed " & Hex(Err.Number)
  550.             exit Function
  551.         End if
  552.         
  553.         'call the method to set the application protection
  554.         objVirDir.AppCreate2( cint(strProtect) )
  555.         If Err.number <> 0 Then
  556.             SA_TraceOut "inc_wsa", "Failed to set the application protection " & Hex(Err.number)
  557.             exit Function
  558.         End if
  559.  
  560.         SetApplProt = TRUE
  561.         
  562.         'Release objects
  563.         set objVirDir = nothing
  564.     End Function
  565.  
  566.     '-------------------------------------------------------------------------
  567.     'Function name:            SetApplRead
  568.     'Description:            Sets Read permissions on the web site
  569.     'Input Variables:        objService, strSiteNum
  570.     'Returns:                boolean
  571.     '--------------------------------------------------------------------------
  572.     Function SetApplRead( objService, strSiteNum)
  573.         On Error Resume Next
  574.         Err.Clear 
  575.  
  576.         Dim strObjPath        'holds Query string
  577.         Dim objVirDir        'holds query result
  578.  
  579.         SetApplRead = FALSE
  580.  
  581.         'set application protection
  582.         strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)  
  583.         
  584.         set objVirDir = objService.Get( strObjPath )
  585.  
  586.         If Err.number <> 0 Then            
  587.             SA_TraceOut "inc_wsa", "get vir dir object failed " & Hex(Err.Number)
  588.             exit Function
  589.         End if
  590.         
  591.         'call the method to set the application Read property        
  592.         objVirDir.AccessRead = true        
  593.         objVirDir.AccessNoRemoteRead = false        
  594.         objVirDir.AccessSource = false 
  595.         objVirDir.Put_( WBEMFLAG )
  596.  
  597.         If Err.number <> 0 Then    
  598.             SA_TraceOut "inc_wsa", "Failed to set the application read property " & Hex(Err.number)
  599.             exit Function
  600.         End if
  601.  
  602.         SetApplRead = TRUE
  603.         
  604.         'Release objects
  605.         set objVirDir =  nothing        
  606.     End Function
  607.  
  608.     '-------------------------------------------------------------------------
  609.     'Function name:            SetAnonProp
  610.     'Description:            Sets the Anon user
  611.     'Input Variables:        objService, strSiteNum, strAllow, strAnonName, strAnonPwd
  612.     'Returns:                boolean
  613.     '--------------------------------------------------------------------------
  614.     Function SetAnonProp(objService, strSiteNum, strAllow, strAnonName, strAnonPwd, bIIS)
  615.         On Error Resume Next
  616.         Err.Clear 
  617.         
  618.         Dim strObjPath        'holds Query string
  619.         Dim objVirDirSet    'holds query result
  620.         Dim strPassword
  621.         Dim strUserName
  622.         Dim objSystem 
  623.         Dim strDomainName
  624.  
  625.         Dim arrDomain
  626.  
  627.         SA_Traceout "parameters=", strSiteNum + ":" + strAllow + ":" + strAnonName + ":" + strAnonPwd
  628.  
  629.         SetAnonProp = FALSE
  630.  
  631.         strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)
  632.         set objVirDirSet = objService.Get(strObjPath)
  633.         
  634.         if Err.number <> 0 then
  635.             SA_TraceOut    "inc_wsa", "Get WebVirtualDirSetting object failed with error " & "(" & Hex(Err.Number) & ")" 
  636.             exit Function
  637.         End if
  638.         
  639.         'Set bIIS to false, that's because a new IIS 6.0 security feature, which does not
  640.         'install sub-authenticator on clean installs. bIIS should always be false.
  641.         'It also affects anon access. Now we don't let IIS manage the pwd, and have to set 
  642.         'the pwd explicitly. Since user can disable/enable the anon access back and forth, 
  643.         'we need to always store the pwd in AnonymousUserPass. The pwd for anon user created 
  644.         'by WebUI is randomly generated from SAHelper, it should not be empty. If it's empty,
  645.         'it means user wants to change the anon access permission.
  646.         bIIS = false
  647.         
  648.         If strAnonPwd <> "" Then
  649.             objVirDirSet.AnonymousUserPass = strAnonPwd
  650.         End If
  651.  
  652.         if lcase(strAllow) = "true" then
  653.             objVirDirSet.AuthAnonymous = True 
  654.             objVirDirSet.AuthBasic = False
  655.             objVirDirSet.AuthNTLM = True
  656.             objVirDirSet.AnonymousUserName = strAnonName
  657.                objVirDirSet.AnonymousPasswordSync = False
  658.  
  659.         else
  660.             objVirDirSet.AuthAnonymous = False
  661.             objVirDirSet.AuthBasic = True
  662.             objVirDirSet.AuthNTLM = True
  663.         end if
  664.         
  665.         objVirDirSet.Put_( WBEMFLAG )
  666.         
  667.         If Err.number <> 0 Then
  668.             SA_TraceOut "inc_wsa", "failed to set the anon settings with error " & "(" & Hex(Err.Number) & ")"
  669.         end if
  670.         
  671.         SetAnonProp = TRUE
  672.         
  673.         'Release objects
  674.         set objVirDirSet =  nothing
  675.     End Function
  676.  
  677.     '-------------------------------------------------------------------------
  678.     'Function name:            SetServerBindings
  679.     'Description:            Sets the IP address, tcp port and host header values
  680.     'Input Variables:        objService, strSiteNum, arrBindings 
  681.     'Returns:                boolean
  682.     '--------------------------------------------------------------------------
  683.     Function SetServerBindings( objService, strSiteNum, arrBindings )
  684.         On Error Resume Next
  685.         Err.Clear 
  686.             
  687.         Dim strObjPath        'holds query string
  688.         Dim objSite            'holds site    
  689.  
  690.         SetServerBindings = FALSE
  691.  
  692.         strObjPath = GetIISWMIProviderClassName("IIs_WebServerSetting") & ".Name=" & chr(34) & strSiteNum & chr(34)
  693.         
  694.         set objSite = objService.Get(strObjPath)
  695.  
  696.         If Err.number <> 0 Then    
  697.             SA_TraceOut "Failed to get the IIs_WebServerSetting object with error " & "(" & Hex(Err.Number) & ")" 
  698.             exit Function
  699.         End if
  700.                 
  701.         SA_TraceOut "inc_wsa", "bindings=" & arrBindings(0)
  702.         
  703.         If IsIIS60Installed() Then
  704.                 
  705.             Dim arrTmp
  706.             Dim arrObjBindings(0)
  707.                 
  708.             'We need to create a ServerBinding object for IIS6.0 WMI    
  709.             arrTmp = split( arrBindings(0),":")
  710.             
  711.             set arrObjBindings(0) = objService.Get("ServerBinding").SpawnInstance_
  712.             
  713.             arrObjBindings(0).IP = arrTmp(0)        'IP Address
  714.             arrObjBindings(0).Port = arrTmp(1)        'Port
  715.             arrObjBindings(0).Hostname = arrTmp(2)    'Hostname - Header in old WMI 
  716.         
  717.             objSite.ServerBindings = arrObjBindings
  718.         Else
  719.             objSite.ServerBindings = arrBindings
  720.         End If
  721.             
  722.             
  723.         objSite.Put_( WBEMFLAG )
  724.  
  725.         If Err.number <> 0 Then
  726.             SA_TraceOut "Failed to set the serverbindings with error " & "(" & Hex(Err.Number) & ")" 
  727.             exit Function
  728.         end if
  729.  
  730.         SetServerBindings = TRUE
  731.         
  732.         'Release objects
  733.         set objSite =  nothing
  734.     End Function
  735.  
  736.     '-------------------------------------------------------------------------
  737.     'Function name:            StartWebSite
  738.     'Description:            Starts web site after creation
  739.     'Input Variables:        objService, strSiteNum
  740.     'Returns:                boolean
  741.     '--------------------------------------------------------------------------
  742.     Function StartWebSite( objService, strSiteNum )
  743.         On Error Resume Next
  744.         Err.Clear
  745.  
  746.         Dim strObjPath        'holds query string
  747.         Dim objWebSite        'holds result site object    
  748.  
  749.         StartWebSite = FALSE
  750.  
  751.         strObjPath = GetIISWMIProviderClassName("IIs_WebServer") & ".Name=" & chr(34) & strSiteNum & chr(34)
  752.  
  753.         Set objWebSite = objService.Get(strObjPath)
  754.  
  755.         If Err.number <> 0 Then
  756.             SA_TraceOut "inc_wsa", "Failed to get the IIs_WebServer Object with error " & strObjPath & "(" & Hex(Err.Number) & ")"  & Err.Description
  757.             exit Function
  758.         End if
  759.  
  760.         if objWebSite.ServerState = CONST_SITE_STOPPED then
  761.             objWebSite.start()
  762.             If Err.number <> 0 Then
  763.                 SA_TraceOut "inc_wsa", "Failed to start the IIs_WebServer Object with error " & "(" & Hex(Err.Number) & ")" 
  764.                 exit Function
  765.             end if
  766.         elseif objWebSite.ServerState = CONST_SITE_PAUSED then
  767.             objWebSite.Continue()
  768.             If Err.number <> 0 Then
  769.                 SA_TraceOut "inc_wsa", "Failed to start the IIs_WebServer Object with error " & "(" & Hex(Err.Number) & ")" 
  770.                 exit Function
  771.             end if
  772.         end if
  773.  
  774.         StartWebSite = TRUE
  775.         
  776.         'Release objects
  777.         Set objWebSite =  nothing
  778.     End Function
  779.  
  780.     '-------------------------------------------------------------------------
  781.     'Function name:            PauseWebSite
  782.     'Description:            Pause web site
  783.     'Input Variables:        objService, strSiteNum
  784.     'Returns:                boolean
  785.     '--------------------------------------------------------------------------
  786.     Function PauseWebSite( objService, strSiteNum )
  787.         On Error Resume Next
  788.         Err.Clear
  789.  
  790.         Dim strObjPath        'holds query string
  791.         Dim objWebSite        'holds result site object    
  792.  
  793.         PauseWebSite = FALSE
  794.  
  795.         strObjPath = GetIISWMIProviderClassName("IIs_WebServer") & ".Name=" & chr(34) & strSiteNum & chr(34)
  796.  
  797.         Set objWebSite = objService.Get(strObjPath)
  798.  
  799.         If Err.number <> 0 Then
  800.             SA_TraceOut "inc_wsa", "Failed to get the IIs_WebServer Object with error " & strObjPath & "(" & Hex(Err.Number) & ")"  & Err.Description
  801.             exit Function
  802.         End if
  803.  
  804.         if objWebSite.ServerState = CONST_SITE_STARTED then
  805.             objWebSite.pause()
  806.             If Err.number <> 0 Then
  807.                 SA_TraceOut "inc_wsa", "Failed to pause the IIs_WebServer Object with error " & "(" & Hex(Err.Number) & ")" 
  808.                 exit Function
  809.             end if
  810.         
  811.         end if
  812.  
  813.         PauseWebSite = TRUE
  814.         
  815.         'Release objects
  816.         Set objWebSite =  nothing
  817.     End Function
  818.  
  819.     '-------------------------------------------------------------------------
  820.     'Function name:            StopWebSite
  821.     'Description:            Starts web site after creation
  822.     'Input Variables:        objService, strSiteNum
  823.     'Returns:                boolean
  824.     '--------------------------------------------------------------------------
  825.     Function StopWebSite( objService, strSiteNum )
  826.         On Error Resume Next
  827.         Err.Clear
  828.  
  829.         Dim strObjPath        'holds query object
  830.         Dim objWebSite        'holds query result
  831.  
  832.         StopWebSite = FALSE
  833.  
  834.         strObjPath = GetIISWMIProviderClassName("IIs_WebServer") & ".Name=" & chr(34) & strSiteNum & chr(34)
  835.  
  836.         Set objWebSite = objService.Get(strObjPath)
  837.         
  838.         If Err.number <> 0 Then
  839.             SA_TraceOut "site_area.asp", "Failed to get the IIs_WebServer Object with error " & strObjPath & "(" & Hex(Err.Number) & ")"  & Err.Description
  840.             exit Function
  841.         End if
  842.         
  843.         if objWebSite.ServerState = CONST_SITE_STARTED or objWebSite.ServerState = CONST_SITE_PAUSED then
  844.             
  845.             objWebSite.Stop()
  846.             If Err.number <> 0 Then
  847.                 SA_TraceOut "site_area.asp", "Failed to stop the IIs_WebServer Object with error " & "(" & Hex(Err.Number) & ")" 
  848.                 exit Function
  849.             end if
  850.         
  851.         end if
  852.  
  853.         StopWebSite = TRUE
  854.         
  855.         'Release objects
  856.         Set objWebSite = nothing
  857.     End Function
  858.  
  859.     '-------------------------------------------------------------------------
  860.     'Function name:        SA_Sleep
  861.     'Description:        Sleep for the given period of time (ms)
  862.     'Input Variables:    Time to sleep in ms
  863.     'Output Variables:    
  864.     'Returns:            None
  865.     'Global Variables:    
  866.     '-------------------------------------------------------------------------
  867.     Public Function SA_Sleep(lngTimeToSleep)
  868.         On Error Resume Next
  869.         Dim objSystem        
  870.         
  871.         Set objSystem = CreateObject("comhelper.SystemSetting")
  872.         If Err.Number <> 0 Then
  873.             Call SA_TraceOut(SA_GetScriptFileName(), "SA_Sleep failed to create COMHelper object: " + CStr(Hex(Err.Number)))
  874.             Set objSystem = Nothing
  875.             Exit Function
  876.         End If
  877.         
  878.         call objSystem.Sleep(lngTimeToSleep)
  879.                 
  880.         If Err.Number <> 0 Then
  881.             Call SA_TraceOut(SA_GetScriptFileName(), "SA_Sleep failed: " + CStr(Hex(Err.Number)))
  882.             Set objSystem = Nothing
  883.             Exit Function
  884.         End If
  885.         
  886.         Set objSystem = Nothing
  887.         
  888.     End Function
  889.     
  890.     '-------------------------------------------------------------------------
  891.     'Function name:            SetAdminFtpServerName
  892.     'Description:            sets the ftp site name in registry
  893.     'Input Variables:        strFTPServerName
  894.     'Returns:                true/false
  895.     'Global variables:        None
  896.     '--------------------------------------------------------------------------
  897.  
  898.     Function SetAdminFtpServerName(strFTPServerName)
  899.         on error resume next        
  900.         Err.clear
  901.  
  902.         Dim IRC
  903.         Dim objGetHandle
  904.         
  905.         SetAdminFtpServerName = FALSE
  906.                 
  907.         set objGetHandle = RegConnection()
  908.                 
  909.         IRC = objGetHandle.SetStringValue(G_HKEY_LOCAL_MACHINE,CONST_WEBBLADES_REGKEY,CONST_FTPSITEID_REGVAL,strFTPServerName)        
  910.         If Err.number <> 0 then
  911.             SA_TraceOut "inc_wsa", "Failed to Set adminFTPServerName regval"
  912.             exit function
  913.         end if
  914.  
  915.         SetAdminFtpServerName = TRUE
  916.  
  917.     End Function
  918.  
  919.     '-------------------------------------------------------------------------
  920.     'Function name:            GetAdminFtpServerName
  921.     'Description:            gets the ftp site id
  922.     'Input Variables:        None
  923.     'Output Variables:        none
  924.     'Returns:                FTP site ID
  925.     '--------------------------------------------------------------------------
  926.     Function GetAdminFtpServerName()
  927.         On Error Resume Next
  928.         Err.Clear 
  929.             
  930.         Dim objGetHandle    'holds regconnection value    
  931.  
  932.         set objGetHandle = RegConnection()        
  933.         
  934.         GetAdminFtpServerName = GetRegKeyValue(objGetHandle,CONST_WEBBLADES_REGKEY,CONST_FTPSITEID_REGVAL,CONST_STRING)
  935.         If Err.number <> 0 then
  936.             GetAdminFtpServerName = ""
  937.             SA_TraceOut "inc_wsa", "Failed to get AdminFtpServerName regval"
  938.             exit function
  939.         end if    
  940.  
  941.     End Function
  942.     
  943.     '-------------------------------------------------------------------------
  944.     'Function name:            IsAdminFTPServerExist
  945.     'Description:            check whether AdminFTPServer exists
  946.     'Input Variables:        None
  947.     'Output Variables:        none
  948.     'Returns:                true/false
  949.     '--------------------------------------------------------------------------
  950.     Function IsAdminFTPServerExist() 
  951.         On Error Resume Next
  952.         Err.Clear 
  953.     
  954.         dim strAdminFTPServerName
  955.         dim objWMIConnection
  956.         dim objAdminFTPServer
  957.         
  958.         IsAdminFTPServerExist = false
  959.         
  960.         strAdminFTPServerName = GetAdminFtpServerName()
  961.         ' If could not read the admin FTP server name from the registry, return false        
  962.         if strAdminFTPServerName = "" Then
  963.             Exit Function
  964.         End if 
  965.         
  966.         ' If could not get admin FTP server from WMI, return false
  967.         set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)                
  968.         Set objAdminFTPServer = objWMIConnection.Get("IIsFtpServer.Name='" & strAdminFTPServerName & "'")
  969.  
  970.         if Err.number <> 0 or (Not IsObject(objAdminFTPServer)) Then
  971.             SA_TraceOut "inc_wsa", "IsAdminFTPServerExist failed"
  972.             Exit Function
  973.         End If
  974.     
  975.         IsAdminFTPServerExist = true
  976.     
  977.     End Function
  978.     
  979.     '-------------------------------------------------------------------------
  980.     'Function name:            IsAdminFTPServerExistAndRunning
  981.     'Description:            check whether AdminFTPServer exists and is running
  982.     'Input Variables:        None
  983.     'Output Variables:        none
  984.     'Returns:                true/false
  985.     '--------------------------------------------------------------------------
  986.     Function IsAdminFTPServerExistAndRunning() 
  987.         On Error Resume Next
  988.         Err.Clear 
  989.     
  990.         dim strAdminFTPServerName
  991.         dim objWMIConnection
  992.         dim objAdminFTPServer
  993.         
  994.         IsAdminFTPServerExistAndRunning = false
  995.         
  996.         strAdminFTPServerName = GetAdminFtpServerName()
  997.         ' If could not read the admin FTP server name from the registry, return false        
  998.         if strAdminFTPServerName = "" Then
  999.             Exit Function
  1000.         End if 
  1001.         
  1002.         ' If could not get admin FTP server from WMI, return false
  1003.         set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)                
  1004.         Set objAdminFTPServer = objWMIConnection.Get("IIsFtpServer.Name='" & strAdminFTPServerName & "'")
  1005.         
  1006.         if Err.number <> 0 or (Not IsObject(objAdminFTPServer)) Then
  1007.             SA_TraceOut "inc_wsa", "IsAdminFTPServerExistAndRunning failed"
  1008.             Exit Function
  1009.         End If
  1010.         
  1011.         ' If admin FTP server is not running, return false        
  1012.         if objAdminFTPServer.ServerState <> CONST_FTPSERVER_RUNNING_STATE Then
  1013.             SA_TraceOut "inc_wsa", "AdminFTPServer is not running"
  1014.             exit function
  1015.         End if
  1016.     
  1017.         IsAdminFTPServerExistAndRunning = true
  1018.     
  1019.     End Function
  1020.     
  1021.     
  1022.     
  1023.     '-------------------------------------------------------------------------
  1024.     'Function name:            IsAdminFTPServerExist
  1025.     'Description:            check whether AdminFTPServer exists
  1026.     'Input Variables:        None
  1027.     'Output Variables:        none
  1028.     'Returns:                true/false
  1029.     '--------------------------------------------------------------------------
  1030.     Function IsAdminFTPServerExist()
  1031.         On Error Resume Next
  1032.         Err.Clear 
  1033.         
  1034.         dim strAdminFTPServerName
  1035.         dim objWMIConnection
  1036.         dim objAdminFTPServer
  1037.         
  1038.         IsAdminFTPServerExist = false
  1039.         
  1040.         strAdminFTPServerName = GetAdminFtpServerName()
  1041.         ' If could not read the admin FTP server name from the registry, return false        
  1042.         if strAdminFTPServerName = "" Then
  1043.             Exit Function
  1044.         End if 
  1045.         
  1046.         ' If could not get admin FTP server from WMI, return false
  1047.         set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)                
  1048.         Set objAdminFTPServer = objWMIConnection.Get("IIsFtpServer.Name='" & strAdminFTPServerName & "'")
  1049.         
  1050.         if Err.number <> 0 or (Not IsObject(objAdminFTPServer)) Then
  1051.             SA_TraceOut "inc_wsa", "IsAdminFTPServerExist fails"
  1052.             Exit Function
  1053.         End If
  1054.     
  1055.         IsAdminFTPServerExist = true
  1056.     
  1057.     End Function
  1058.     
  1059.     
  1060.     '-------------------------------------------------------------------------
  1061.     'Function name:            StartAdminFTPServer
  1062.     'Description:            Start Admin FTP Server
  1063.     'Input Variables:        None
  1064.     'Output Variables:        none
  1065.     'Returns:                true/false
  1066.     '--------------------------------------------------------------------------    
  1067.     Function StartAdminFTPServer()
  1068.         On Error Resume Next
  1069.         Err.Clear 
  1070.         
  1071.         dim strAdminFTPServerName
  1072.         dim objWMIConnection
  1073.         dim objAdminFTPServer
  1074.         
  1075.         StartAdminFTPServer = false
  1076.         
  1077.         strAdminFTPServerName = GetAdminFtpServerName()
  1078.         ' If could not read the admin FTP server name from the registry, return false        
  1079.         if strAdminFTPServerName = "" Then
  1080.             Exit Function
  1081.         End if 
  1082.         
  1083.         ' If could not get admin FTP server from WMI, return false
  1084.         set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)                
  1085.         Set objAdminFTPServer = objWMIConnection.Get("IIsFtpServer.Name='" & strAdminFTPServerName & "'")
  1086.                                 
  1087.         if objAdminFTPServer.ServerState <> CONST_FTPSERVER_RUNNING_STATE Then            
  1088.             objAdminFTPServer.Start    
  1089.         Else
  1090.             SA_TraceOut "inc_wsa", "Admin FTP Server is already started"            
  1091.         End if        
  1092.             
  1093.         if Err.number <> 0 Then
  1094.             SA_TraceOut "inc_wsa", "StartAdminFTPServer failed: " & err.Description 
  1095.             Exit Function
  1096.         End If
  1097.     
  1098.         StartAdminFTPServer = true
  1099.     
  1100.     End Function
  1101.     
  1102.     
  1103.     '-------------------------------------------------------------------------
  1104.     'Function name:            StopAdminFTPServer
  1105.     'Description:            Stop Admin FTP Server
  1106.     'Input Variables:        None
  1107.     'Output Variables:        none
  1108.     'Returns:                true/false
  1109.     '--------------------------------------------------------------------------    
  1110.     Function StopAdminFTPServer()
  1111.         On Error Resume Next
  1112.         Err.Clear 
  1113.         
  1114.         dim strAdminFTPServerName
  1115.         dim objWMIConnection
  1116.         dim objAdminFTPServer
  1117.         
  1118.         StopAdminFTPServer = false
  1119.         
  1120.         strAdminFTPServerName = GetAdminFtpServerName()
  1121.         ' If could not read the admin FTP server name from the registry, return false        
  1122.         if strAdminFTPServerName = "" Then
  1123.             Exit Function
  1124.         End if 
  1125.         
  1126.         ' If could not get admin FTP server from WMI, return false
  1127.         set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)                
  1128.         Set objAdminFTPServer = objWMIConnection.Get("IIsFtpServer.Name='" & strAdminFTPServerName & "'")
  1129.         
  1130.         if objAdminFTPServer.ServerState = CONST_FTPSERVER_RUNNING_STATE Then                        
  1131.             objAdminFTPServer.Stop
  1132.         Else
  1133.             SA_TraceOut "inc_wsa", "Admin FTP Server is already stopped"            
  1134.         End if    
  1135.             
  1136.         if Err.number <> 0 Then
  1137.             SA_TraceOut "inc_wsa", "StopAdminFTPServer failed"
  1138.             Exit Function
  1139.         End If
  1140.     
  1141.         StopAdminFTPServer = true
  1142.     
  1143.     End Function
  1144.     
  1145.     
  1146.     '-------------------------------------------------------------------------
  1147.     'Function name:            StopDefaultFTPServer
  1148.     'Description:            Before starting admin FTP server, we need try to stop
  1149.     '                        the default FTP server. If it cannot be stopped, or the
  1150.     '                        the running FTP server is not the default FTP server (nor
  1151.     '                        the admin FTP server), return false. Return true otherwise.
  1152.     'Input Variables:        None
  1153.     'Output Variables:        none
  1154.     'Returns:                true/false
  1155.     '--------------------------------------------------------------------------    
  1156.     Function StopDefaultFTPServer()         
  1157.         On Error Resume Next
  1158.         Err.Clear 
  1159.         
  1160.         dim objWMIConnection        
  1161.         dim objFTPServers
  1162.         dim instFTPServer
  1163.         Const TIME_TO_SLEEP = 500   ' Sleep 1/2 second
  1164.         
  1165.         StopDefaultFTPServer = false        
  1166.                 
  1167.         set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)                                
  1168.         Set objFTPServers = objWMIConnection.InstancesOf(GetIISWMIProviderClassName("IIsFtpServer"))
  1169.                         
  1170.         if Err.number <> 0 Then                         
  1171.             SA_TraceOut "inc_wsa", "Fail to stop Default FTP Server:" & err.number 
  1172.             exit function
  1173.         end if
  1174.         
  1175.         if objFTPServers.count = 0 then
  1176.             ' If there is not FTP site, return true
  1177.             StopDefaultFTPServer = true
  1178.             exit function
  1179.         End If
  1180.                     
  1181.         for each instFTPServer in objFTPServers
  1182.             
  1183.             'If running site is not default FTP site, return false since we don't want
  1184.             'to stop any FTP site other than the default FTP site
  1185.             if instFTPServer.ServerState = CONST_FTPSERVER_RUNNING_STATE And instFTPServer.Name <> "MSFTPSVC/1" Then
  1186.                 exit function 
  1187.             End If
  1188.             
  1189.             'If it's default site, stop it if it's running
  1190.             if instFTPServer.Name = "MSFTPSVC/1" Then
  1191.                 if instFTPServer.ServerState <> CONST_FTPSERVER_RUNNING_STATE Then
  1192.                     StopDefaultFTPServer = true
  1193.                     Exit Function
  1194.                 Else
  1195.                                 
  1196.                     instFTPServer.Stop
  1197.                     
  1198.                     Dim iCounter
  1199.                     
  1200.                     For iCounter = 0 to 10 'loop for 10 times
  1201.                     
  1202.                         'Requery the WMI for the state of the default FTP server
  1203.                         Set instFTPServer = objWMIConnection.Get("IIsFtpServer.Name='MSFTPSVC/1'")
  1204.                                         
  1205.                         If instFTPServer.ServerState = CONST_FTPSERVER_STOPPED_STATE Then
  1206.                             StopDefaultFTPServer = true
  1207.                             Exit Function
  1208.                         Else
  1209.                             call SA_Sleep(TIME_TO_SLEEP)                            
  1210.                         End If                        
  1211.                     Next
  1212.                                     
  1213.                     if Err.number <> 0 Then
  1214.                         SA_TraceOut "inc_wsa.asp", "Failed to stop default FTP site"
  1215.                         Exit Function
  1216.                     End If
  1217.                     
  1218.                     StopDefaultFTPServer = true
  1219.                     Exit Function
  1220.                                     
  1221.                 End If
  1222.             End If
  1223.     
  1224.         Next
  1225.         
  1226.     End Function
  1227.         
  1228.     '-------------------------------------------------------------------------
  1229.     'Function name:            CreateAdminFTPServer
  1230.     'Description:            Create FTP server for Updating Website Content and save
  1231.     '                        the server name to the registry
  1232.     'Input Variables:        None
  1233.     'Output Variables:        none
  1234.     'Returns:                true/false
  1235.     '--------------------------------------------------------------------------    
  1236.     Function CreateAdminFTPServer()
  1237.     
  1238.         On Error Resume Next
  1239.         Err.Clear 
  1240.             
  1241.         Dim strName
  1242.         Dim strRoot
  1243.         Dim strPort
  1244.         Dim objWMIConnection
  1245.         Dim Bindings
  1246.         Dim objFTPService
  1247.         Dim strSiteObjPath
  1248.         Dim strSitePath
  1249.         Dim objPath
  1250.         Dim objSetting
  1251.         Dim objSysDrive
  1252.         Dim strSysDrive
  1253.         
  1254.         CreateAdminFTPServer = false
  1255.         
  1256.         'Get FTP site root dir    
  1257.         Set objSysDrive = server.CreateObject("Scripting.FileSystemObject")
  1258.         Call GetFTPSiteRootVal(strRoot)
  1259.         
  1260.         'If the root dir does not exist, create it
  1261.         If objSysDrive.FolderExists(strRoot)=false Then
  1262.             call CreateSitePath(objSysDrive, strRoot)
  1263.         End If
  1264.                 
  1265.         strName = "Web Site Content"    
  1266.         strPort = "21"
  1267.                 
  1268.         set objWMIConnection = getWMIConnection(CONST_WMI_IIS_NAMESPACE)        
  1269.                 
  1270.         Bindings = Array(0)
  1271.         Set Bindings(0) = objWMIConnection.get("ServerBinding").SpawnInstance_()
  1272.         Bindings(0).IP = ""    'all unsigned 
  1273.         Bindings(0).Port = strPort
  1274.         
  1275.         'Create and start the admin FTP site
  1276.         Set objFTPService = objWMIConnection.Get("IIsFtpService='MSFTPSVC'")
  1277.         strSiteObjPath = objFTPService.CreateNewSite(strName, Bindings, strRoot)
  1278.         
  1279.         If err.number <> 0 Then
  1280.             sa_traceout "inc_wsa", "Failed to create admin FTP site " & err.Description 
  1281.             Exit Function
  1282.         End If
  1283.  
  1284.         ' Parse site ID out of WMI object path
  1285.         Set objPath = CreateObject("WbemScripting.SWbemObjectPath")
  1286.         objPath.Path = strSiteObjPath
  1287.         strSitePath = objPath.Keys.Item("")
  1288.  
  1289.         ' Set ftp virtual directory properties
  1290.         Set objSetting = objWMIConnection.Get("IIsFtpServerSetting.Name='" & strSitePath & "'")
  1291.     
  1292.         objSetting.AllowAnonymous = false
  1293.         objSetting.AccessRead    = true
  1294.         objSetting.AccessWrite    = false        
  1295.         objSetting.UserIsolationMode = 0 'not using the user isolation mode
  1296.         objSetting.Put_()
  1297.         
  1298.         'Save the admin FTP server name to registry
  1299.         call SetAdminFTPServerName(strSitePath)
  1300.         
  1301.         If err.number <> 0 Then
  1302.             sa_traceout "inc_wsa", "Failed to create admin FTP site " & err.Description 
  1303.             Exit Function
  1304.         End If
  1305.         
  1306.         CreateAdminFTPServer = true
  1307.                         
  1308.     End Function
  1309.     
  1310.     '-------------------------------------------------------------------------
  1311.     'Function name:            GetWebSiteRootVal
  1312.     'Description:            gets the web site root dir
  1313.     'Input Variables:        None
  1314.     'Output Variables:        strWebRootDir
  1315.     'Returns:                error num
  1316.     '--------------------------------------------------------------------------
  1317.     Function GetWebSiteRootVal(ByRef strWebRootDir)
  1318.         On Error Resume Next
  1319.         Err.Clear 
  1320.         
  1321.         Dim IRC                'holds return value
  1322.         Dim objGetHandle    'holds regconnection value    
  1323.  
  1324.         set objGetHandle = RegConnection()        
  1325.         
  1326.         IRC = ""
  1327.         IRC = GetRegKeyValue(objGetHandle,CONST_WEBBLADES_REGKEY,CONST_WEBSITEROOT_REGVAL,CONST_STRING)
  1328.         If Err.number <> 0 then
  1329.             GetWebSiteRootVal = Err.number
  1330.             SA_TraceOut "inc_wsa", "Failed to get the web root dir val from reg"
  1331.             exit function
  1332.         end if
  1333.  
  1334.         set objGetHandle = nothing        
  1335.  
  1336.         if IRC = "" then
  1337.             Dim objSysDrive,strSysDrive
  1338.             Set objSysDrive = server.CreateObject("Scripting.FileSystemObject")
  1339.             strSysDrive = objSysDrive.GetSpecialFolder(1).Drive ' 1 for systemfolder,0 for windows folder
  1340.             strWebRootDir = strSysDrive & "\" & CONST_DEF_WEBROOT
  1341.         else
  1342.             strWebRootDir = IRC
  1343.         end if
  1344.         
  1345.         set objSysDrive = nothing
  1346.  
  1347.         GetWebSiteRootVal = CONST_SUCCESS
  1348.     End Function
  1349.     
  1350.     '-------------------------------------------------------------------------
  1351.     'Function name:            GetFTPSiteRootVal
  1352.     'Description:            gets the FTP site roor dir
  1353.     'Input Variables:        None
  1354.     'Output Variables:        strWebRootDir
  1355.     'Returns:                error num
  1356.     '--------------------------------------------------------------------------
  1357.     Function GetFTPSiteRootVal(ByRef strWebRootDir)
  1358.         On Error Resume Next
  1359.         Err.Clear 
  1360.                 
  1361.         Dim IRC                'holds return value
  1362.         Dim objGetHandle    'holds registry connection    
  1363.  
  1364.         set objGetHandle = RegConnection()        
  1365.         
  1366.         IRC = ""
  1367.         
  1368.         IRC = GetRegKeyValue(objGetHandle,CONST_WEBBLADES_REGKEY,CONST_FTPSITEROOT_REGVAL,CONST_STRING)
  1369.         If Err.number <> 0 then
  1370.             ' Ignore registry error and use default value.
  1371.             IRC = ""
  1372.         end if
  1373.  
  1374.         set objGetHandle = nothing
  1375.  
  1376.         if IRC = "" then
  1377.             Dim objSysDrive,strSysDrive
  1378.             
  1379.             Set objSysDrive = server.CreateObject("Scripting.FileSystemObject")
  1380.             strSysDrive = objSysDrive.GetSpecialFolder(1).Drive ' 1 for systemfolder,0 for windows folder
  1381.             strWebRootDir = strSysDrive & "\" & CONST_DEF_FTPROOT
  1382.             
  1383.             set objSysDrive = nothing
  1384.         else
  1385.             strWebRootDir = IRC
  1386.         end if
  1387.         
  1388.         GetFTPSiteRootVal = CONST_SUCCESS
  1389.     End Function
  1390.  
  1391.     '----------------------------------------------------------------------------
  1392.     'Function name        :CreateSitePath
  1393.     'Description        :Create Directory path if not exists
  1394.     'Input Variables    :None
  1395.     'Output Variables    :None
  1396.     'Returns            :Boolean
  1397.     'Global Variables    :None    
  1398.     '----------------------------------------------------------------------------    
  1399.     Function CreateSitePath(objFso, strRootDir)
  1400.         on error resume next
  1401.         Err.Clear
  1402.         
  1403.         Dim strIndx                'holds index value
  1404.         Dim strDriveName        'holds drive name
  1405.         Dim strDirStruct        'holds directory path    
  1406.         Dim strDirList        
  1407.         Dim strMain                
  1408.         Dim count 
  1409.         Dim strEachDir
  1410.         Dim strCreateDir
  1411.         Dim objDirList
  1412.         Dim objDir
  1413.         Dim objDriveType
  1414.         
  1415.         strIndx = instr(1,strRootDir,":\")
  1416.         strDriveName = left(strRootDir,strIndx)
  1417.         strDirStruct = mid(strRootDir,strIndx+1)
  1418.         strDirList = split(strDirStruct,"\")
  1419.         
  1420.         if NOT objFso.DriveExists(ucase(strDriveName)) then
  1421.             CreateSitePath = CONST_INVALID_DRIVE
  1422.             exit function
  1423.         end if
  1424.  
  1425.         set objDriveType =  objFso.GetDrive(strDriveName)
  1426.         if objDriveType.FileSystem <> "NTFS" then
  1427.             CreateSitePath = CONST_NOTNTFS_DRIVE
  1428.             exit function
  1429.         end if
  1430.         
  1431.         for count = 0 to UBound(strDirList)
  1432.             if count>=UBound(strDirList) then exit for
  1433.             if count=0 then
  1434.                 strMain = strDriveName & "\" & strDirList(count+1)
  1435.                 if objFso.FolderExists(strMain)=false then
  1436.                     objFso.CreateFolder(strMain)
  1437.                     if err.number <> 0 then
  1438.                         SA_TraceOut "inc_wsa", "CreateSitePath:Failed to create dir " & "(" & Hex(Err.Number) & ")" & Err.Description
  1439.                         CreateSitePath = CONST_FAILED_TOCREATE_DIR
  1440.                         Exit Function
  1441.                     end if
  1442.                 end if
  1443.             else
  1444.                 strEachDir = strEachDir & "\" & strDirList(count+1)
  1445.                 strCreateDir = strMain & strEachDir
  1446.                 if objFso.FolderExists(strCreateDir)=false then
  1447.                    objFso.CreateFolder(strCreateDir)
  1448.                     if err.number <> 0 then
  1449.                         SA_TraceOut "inc_wsa", "CreateSitePath: Failed to create directory " & "(" & Hex(Err.Number) & ")"    & Err.Description
  1450.                         CreateSitePath = CONST_FAILED_TOCREATE_DIR
  1451.                         Exit Function
  1452.                     end if
  1453.                 end if
  1454.             end if
  1455.         next
  1456.                 
  1457.         CreateSitePath = CONST_SUCCESS
  1458.     end function 
  1459.  
  1460.  
  1461.     '----------------------------------------------------------------------------
  1462.     'Function name        :DelegateOuToSiteAdmin
  1463.     'Description        :Delegate Permissions to Site-Identifier_Admins group
  1464.     'Input Variables    :strOu, strTrustee
  1465.     'Output Variables    :None
  1466.     'Returns            :Boolean
  1467.     'Global Variables    :None    
  1468.     '----------------------------------------------------------------------------    
  1469.     Function DelegateOuToSiteAdmin(strOu, strTrustee)
  1470.         On Error Resume Next
  1471.         Err.Clear 
  1472.         
  1473.         Dim strDn                    'holds query value
  1474.         Dim oRootDSE                'holds root value    
  1475.         Dim oDelegationOU             
  1476.         Dim oSecDescriptor 
  1477.         Dim oAcl
  1478.  
  1479.         DelegateOuToSiteAdmin = FALSE
  1480.  
  1481.         Set oRootDSE = GetObject("LDAP://RootDSE")
  1482.  
  1483.         strDn = "ou=" & strOu & ",ou=WebSites," & oRootDSE.Get("DefaultNamingContext")
  1484.  
  1485.         SA_TraceOut "inc_wsa", "strDn=" & strDn
  1486.  
  1487.         ' Get the security descriptor from the object
  1488.         Set oDelegationOU = GetObject("LDAP://" & strDN)
  1489.         
  1490.         Set oSecDescriptor  = oDelegationOU.Get("ntSecurityDescriptor")
  1491.         Set oAcl = oSecDescriptor.DiscretionaryAcl
  1492.  
  1493.         'Give ability to read this object
  1494.         ' Grant a Read permission
  1495.         ' Allow Ace
  1496.         ' Apply to this object only
  1497.         ' ObjectType is not present
  1498.         ' No specific class
  1499.         ' No children will inherit
  1500.  
  1501.         if NOT AddAceToAcl ( oAcl, strTrustee, ADS_RIGHT_GENERIC_READ, ADS_ACETYPE_ACCESS_ALLOWED, 0, 0, "", "" ) then
  1502.             SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1503.             exit function
  1504.         end if
  1505.  
  1506.         'Give ability to create and delete users
  1507.         ' Allow create and delete right
  1508.         ' Allow object ace, This applies to this object and children
  1509.         ' ObjectType is present
  1510.         ' Applies to User object
  1511.         ' No children will inherit
  1512.         if NOT AddAceToAcl (oAcl, strTrustee, ADS_RIGHT_DS_CREATE_CHILD OR ADS_RIGHT_DS_DELETE_CHILD, _ 
  1513.                 ADS_ACETYPE_ACCESS_ALLOWED_OBJECT, ADS_ACEFLAG_INHERIT_ACE, _                  
  1514.                 ADS_FLAG_OBJECT_TYPE_PRESENT, USERGUID, "" ) then
  1515.             
  1516.             SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1517.             exit function
  1518.  
  1519.         end if
  1520.  
  1521.         'Give full control over user objects
  1522.         ' Grant full control
  1523.         ' Allow Ace for an object
  1524.         ' This should be applied only to children, not to this object
  1525.         ' ObjectType is present
  1526.         ' Applies to User class
  1527.         ' No children will inherit
  1528.  
  1529.         if NOT AddAceToAcl ( oAcl, strTrustee, ADS_RIGHT_GENERIC_ALL,     ADS_ACETYPE_ACCESS_ALLOWED_OBJECT, _                  
  1530.                 ADS_ACEFLAG_INHERIT_ACE Or ADS_ACEFLAG_INHERIT_ONLY_ACE, _      
  1531.                 ADS_FLAG_INHERITED_OBJECT_TYPE_PRESENT, "", USERGUID ) then
  1532.             
  1533.             SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1534.             exit function
  1535.  
  1536.         end if
  1537.  
  1538.         'Give ablity to read this OU
  1539.         ' Grant a Read
  1540.         ' Allow Ace
  1541.         ' Apply to this object only
  1542.         ' ObjectType is present
  1543.         ' This applies to the OU class
  1544.         ' No children will inherit
  1545.         if NOT AddAceToAcl ( oAcl, strTrustee, ADS_RIGHT_GENERIC_READ, ADS_ACETYPE_ACCESS_ALLOWED, _    
  1546.                 0, ADS_FLAG_OBJECT_TYPE_PRESENT, OUGUID, "" ) then
  1547.  
  1548.                 SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1549.                 exit function
  1550.  
  1551.         end if
  1552.         
  1553.         'Give ability to create and delete group objects
  1554.         ' Allow create and delete right
  1555.         ' Allow object ace
  1556.         ' This applies to this object only
  1557.         ' ObjectType is present
  1558.         ' Applies to group object
  1559.         ' No children will inherit an objectAce
  1560.  
  1561.         if NOT AddAceToAcl ( oAcl, strTrustee, ADS_RIGHT_DS_CREATE_CHILD OR ADS_RIGHT_DS_DELETE_CHILD, _
  1562.                 ADS_ACETYPE_ACCESS_ALLOWED_OBJECT, ADS_ACEFLAG_INHERIT_ACE, _
  1563.                 ADS_FLAG_OBJECT_TYPE_PRESENT, GROUPGUID, "" ) then
  1564.  
  1565.                 SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1566.                 exit function
  1567.  
  1568.         end if
  1569.  
  1570.         'Give full control to group objects
  1571.         ' Grant full control
  1572.         ' Allow Ace for an object
  1573.         ' This should be applied only to children, not to this object
  1574.         ' ObjectType is present
  1575.         ' Applies to group object
  1576.         ' No children will inherit an objectAce
  1577.  
  1578.         if NOT AddAceToAcl ( oAcl, strTrustee, ADS_RIGHT_GENERIC_ALL, ADS_ACETYPE_ACCESS_ALLOWED_OBJECT, _    
  1579.                 ADS_ACEFLAG_INHERIT_ACE Or ADS_ACEFLAG_INHERIT_ONLY_ACE, _
  1580.                 ADS_FLAG_INHERITED_OBJECT_TYPE_PRESENT, "", GROUPGUID ) then
  1581.  
  1582.                 SA_TraceOut "inc_wsa", "AddAceToAcl failed "
  1583.                 exit function
  1584.  
  1585.         end if
  1586.  
  1587.  
  1588.         'Commit all of the changes to the Active Directory
  1589.  
  1590.         oSecDescriptor.DiscretionaryAcl = oAcl
  1591.         oDelegationOU.Put "ntSecurityDescriptor", oSecDescriptor
  1592.         oDelegationOU.SetInfo
  1593.         if Err.Number <> 0 then
  1594.             Exit Function
  1595.         end if
  1596.  
  1597.         DelegateOuToSiteAdmin = TRUE
  1598.  
  1599.     End Function
  1600.  
  1601.  
  1602.  
  1603.     '=========================================================================================================================
  1604.     ' The AddAceToAcl function will create a new Access control entry.  It will set the trustee to the global trustee variable
  1605.     ' passed into the script.  The other attibutes of the ACE are determined by the parameters.  The ACE is added to the 
  1606.     ' global oACL variable.
  1607.     '=========================================================================================================================
  1608.     Function AddAceToAcl(oAcl, strTrustee, iAccessMask, iAceType, iAceFlags, iFlags, strObjectGUID, strInheritGUID)
  1609.         On Error Resume Next
  1610.         Err.Clear 
  1611.         
  1612.         Dim oAce    'As IADsAccessControlEntry
  1613.  
  1614.         AddAceToAcl = FALSE
  1615.  
  1616.         set oAce = CreateObject("AccessControlEntry")
  1617.         
  1618.         if Err.Number <> 0 then
  1619.             SA_TraceOut "inc_wsa", "CreateObject AccessControlEntry  failed " & "(" & Hex(Err.Number) & ")"
  1620.             Exit Function
  1621.         end if
  1622.  
  1623.         oAce.Trustee = strTrustee
  1624.         oAce.AccessMask = iAccessMask
  1625.         oAce.AceType = iAceType
  1626.         oAce.Flags = iFlags
  1627.         oAce.AceFlags = iAceFlags
  1628.         If Len(strObjectGUID) > 0 then
  1629.           oAce.ObjectType = strObjectGUID
  1630.         End If
  1631.         If Len(strInheritGUID) > 0 then
  1632.           oAce.InheritedObjectType = strInheritGUID
  1633.         End If
  1634.         
  1635.         oACL.AddAce oAce
  1636.         if Err.Number <> 0 then
  1637.             SA_TraceOut "inc_wsa", "Add ace to acl failed " & "(" & Hex(Err.Number) & ")"
  1638.             Exit Function
  1639.         end if
  1640.  
  1641.         AddAceToAcl = TRUE
  1642.         Set oAce = nothing
  1643.     End Function    
  1644.  
  1645.  
  1646.     '-------------------------------------------------------------------------
  1647.     'Function name        :GetNonInheritedSites
  1648.     'Description        :Gets all sites that are not Inheriting settings from the master
  1649.     'Input Variables    :objService,strClassName,strMasterClassName,arrProp
  1650.     'Output Variables    :None
  1651.     'Returns            :Boolean
  1652.     '-------------------------------------------------------------------------
  1653.     Function GetNonInheritedSites(objService,strClassName,strMasterClassName,arrProp)
  1654.         On Error Resume Next
  1655.         Err.Clear 
  1656.             
  1657.         Dim strQuery            'holds query string
  1658.         Dim objInstances        'holds instance values
  1659.         Dim objInst
  1660.         Dim count
  1661.         Dim strPropCollection    'holds prop collection    
  1662.         Dim arrMasterPropVal        
  1663.         Dim strTemp
  1664.         Dim arrWebSites            'holds array of web sites
  1665.         Dim strManagedSites        'holds managed websites value    
  1666.         Dim managedCount        'holds managed count value
  1667.     
  1668.         redim arrMasterPropVal(ubound(arrProp))
  1669.         
  1670.         if strClassName = GetIISWMIProviderClassName("IIS_FTPServerSetting") then
  1671.             arrWebSites = getManagedFTPSites
  1672.         else
  1673.             arrWebSites = getManagedWebSites
  1674.         end if
  1675.         
  1676.         if arrWebSites = 0 then
  1677.             GetNonInheritedSites = 0
  1678.             exit function
  1679.         end if
  1680.  
  1681.         for count =0 to UBound(arrProp)
  1682.             strPropCollection = strPropCollection & arrProp(count) & ","
  1683.         next
  1684.         
  1685.         strPropCollection = left(strPropCollection,len(strPropCollection)-1)
  1686.         
  1687.         strQuery = "select " & strPropCollection & " from " & strMasterClassName
  1688.         
  1689.         set objInstances = objService.ExecQuery(strQuery)
  1690.                 
  1691.         for each objInst in objInstances
  1692.  
  1693.             for count =  0 to UBound(arrProp)
  1694.                 if  vartype(objInst.Properties_.Item(arrProp(count))) = 11 then    '11 for boolean
  1695.                     'if the property type is boolean, we cannot convert it to a string directly
  1696.                     'string conversion of vbscript is browser preference dependent
  1697.                     'we need to convert boolean to english strings(true/false), otherwise wmi query fails
  1698.                     if objInst.Properties_.Item(arrProp(count)) then
  1699.                         arrMasterPropVal(count) = "'" & "True" & "'"
  1700.                     else
  1701.                         arrMasterPropVal(count) = "'" & "False" & "'"
  1702.                     end if
  1703.                 elseif vartype(objInst.Properties_.Item(arrProp(count))) = 8 then '8 for string
  1704.                     arrMasterPropVal(count) = "'" & objInst.Properties_.Item(arrProp(count)) & "'"
  1705.  
  1706.                 elseif vartype(objInst.Properties_.Item(arrProp(count))) = 3 then '3 for integer
  1707.                     arrMasterPropVal(count) = objInst.Properties_.Item(arrProp(count))
  1708.                 
  1709.                 end if
  1710.             
  1711.             next
  1712.  
  1713.         next
  1714.  
  1715.         'Release objects
  1716.         set objInstances = nothing
  1717.                 
  1718.         for count = 0 to UBound(arrProp)
  1719.             strTemp = strTemp &  arrProp(count)  & " !=" & arrMasterPropVal(count) & " or "
  1720.         next
  1721.     
  1722.         strTemp = left(strTemp,len(strTemp)-3)
  1723.         
  1724.         strTemp = " ( " & strTemp & " ) "
  1725.         
  1726.         for managedCount = 0 to UBound(arrWebSites)
  1727.             if strClassName = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") then 
  1728.                 strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "/Root' and " & strTemp & " or "
  1729.             else
  1730.                 strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "' and " & strTemp & " or "
  1731.             end if
  1732.         next
  1733.         strManagedSites = left(strManagedSites,len(strManagedSites)-3)
  1734.         strQuery = "select * from " & strClassName & " where " & strManagedSites 
  1735.  
  1736.         set objInstances = objService.ExecQuery(strQuery)
  1737.         set GetNonInheritedSites = objInstances
  1738.     End Function
  1739.     
  1740.     '-------------------------------------------------------------------------
  1741.     'Function name:        getManagedWebSites
  1742.     'Description:        Returns an array of Managed web sites from reg loc 
  1743.     '                    WebServerAppliance\ManagedWebSites
  1744.     'Input Variables:    None
  1745.     'Output Variables:    
  1746.     'Returns:        returns an array
  1747.     'Global Variables:    None
  1748.     'If object fails dislays the error message
  1749.     '-------------------------------------------------------------------------
  1750.     Function getManagedWebSites()
  1751.         On Error Resume Next
  1752.         Err.Clear 
  1753.  
  1754.         Dim Child            'hold child object
  1755.         Dim count            
  1756.         Dim arrWebSites()    'hold array of websites    
  1757.         Dim objService        'hold WMI Connection object
  1758.         Dim siteCollection    'hold site collection    
  1759.         Dim strQuery        'hold query string    
  1760.         
  1761.         Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  1762.         
  1763.         'form the query
  1764.         strQuery = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where ServerID = ServerComment"
  1765.  
  1766.         Set siteCollection = objService.ExecQuery(strQuery)',"WQL",48)
  1767.         
  1768.         If Err.number   <>  0 Then 
  1769.            SA_ServeFailurepage L_INFORMATION_ERRORMESSAGE
  1770.            getObjSiteCollection = false
  1771.           exit function
  1772.        End If  
  1773.         
  1774.         if siteCollection.count = 0 then
  1775.             getManagedWebSites = 0
  1776.             exit function
  1777.         end if
  1778.         
  1779.         count =0
  1780.         For Each Child In siteCollection 
  1781.             redim preserve arrWebSites(count)
  1782.             arrWebSites(count) = Child.Name
  1783.             count = count + 1
  1784.         Next
  1785.         
  1786.         'use the script managed_site.vbs here        
  1787.          getManagedWebSites = arrWebSites
  1788.          
  1789.         'Release the object
  1790.         set siteCollection = nothing
  1791.         set objService = nothing
  1792.                  
  1793.      End function
  1794.  
  1795.     '-------------------------------------------------------------------------
  1796.     'Function name:        getManagedFTPSites
  1797.     'Description:        Returns an array of Managed FTP sites from reg loc 
  1798.     '                    WebServerAppliance\ManagedWebSites
  1799.     'Input Variables:    None
  1800.     'Output Variables:    
  1801.     'Returns:        returns an array
  1802.     'Global Variables:    None
  1803.     'If object fails dislays the error message
  1804.     '-------------------------------------------------------------------------
  1805.     Function getManagedFTPSites()
  1806.         On Error Resume Next
  1807.         Err.Clear 
  1808.         
  1809.         Dim Child
  1810.         Dim count
  1811.         Dim arrFTPSites()        'holds array of FTP sites
  1812.         Dim objService
  1813.         Dim siteCollection
  1814.         Dim strQuery
  1815.         
  1816.         Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  1817.  
  1818.         'form the query
  1819.         strQuery = "select * from " & GetIISWMIProviderClassName("IIs_FTPServerSetting")
  1820.         Set siteCollection = objService.ExecQuery(strQuery)
  1821.         If Err.number   <>  0 Then 
  1822.             SA_ServeFailurepage L_INFORMATION_ERRORMESSAGE
  1823.             getObjSiteCollection = false
  1824.             exit function
  1825.         End If
  1826.         
  1827.         if siteCollection.count = 0 then
  1828.             getManagedFTPSites = 0
  1829.             exit function
  1830.         end if
  1831.         
  1832.         count =0
  1833.         For Each Child In siteCollection
  1834.             redim preserve arrFTPSites(count)
  1835.             arrFTPSites(count) = Child.Name
  1836.             count = count + 1
  1837.         Next
  1838.  
  1839.          getManagedFTPSites = arrFTPSites
  1840.          
  1841.          'Release objects
  1842.          set objService = nothing
  1843.          set siteCollection = nothing
  1844.          
  1845.      End function
  1846.  
  1847.     '-------------------------------------------------------------------------
  1848.     'Function name        :SetDaclForFtpDir
  1849.     'Description        :Sets DACL entries for FTP directory
  1850.     'Input Variables    :bAllowFTP, strDir, AdminName, AnonName, FTPName, strDirRoot
  1851.     'Output Variables    :None
  1852.     'Returns            :Boolean
  1853.     '-------------------------------------------------------------------------
  1854.     Function SetDaclForFtpDir(bAllowFTP, strDir, strAdminName, strAnonName, strFTPName, strDirRoot)
  1855.         On Error Resume Next
  1856.         Err.Clear
  1857.  
  1858.         SetDaclForFtpDir = FALSE
  1859.         
  1860.         Dim objService            'holds WMI Connection    
  1861.         Dim strTemp                
  1862.         Dim objSecSetting
  1863.         Dim objSecDescriptor    'holds Security descriptor value
  1864.         Dim strPath                'holds path
  1865.         Dim objDACL        
  1866.         Dim objSiteAdminAce        'holds site admin ace
  1867.         Dim objAdminAce            'holds admin ace
  1868.         Dim objAnonAce            'holds anon ace
  1869.         Dim objAuthAce            'holds auth ace    
  1870.         Dim objFTPAce            'hold FTP ace
  1871.         Dim retval                'holds return value
  1872.         
  1873.             
  1874.         Set objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  1875.         objService.security_.impersonationlevel = 3
  1876.  
  1877.         'get the sec seting for file
  1878.         strPath = "Win32_LogicalFileSecuritySetting.Path='" & strDir & "'"
  1879.         set objSecSetting = objService.Get(strPath)
  1880.  
  1881.         if Err.number <> 0 then
  1882.             SA_TraceOut "inc_wsa", "Failed to get Sec object for dir " & "(" & Hex(Err.Number) & ")"
  1883.             exit function
  1884.         end if
  1885.  
  1886.         'get the ace's for all req users
  1887.  
  1888.         if NOT GetUserAce(objService, strAdminName , strDirRoot, CONST_FULLCONROL, objSiteAdminAce ) then
  1889.             SA_TraceOut "inc_wsa", "Failed to get ACE object for Site Admin user " & "(" & Hex(Err.Number) & ")"
  1890.             exit function
  1891.         end if
  1892.  
  1893.         if NOT GetUserAce(objService, SA_GetAccount_Administrator() , strDirRoot, CONST_FULLCONROL, objAdminAce ) then
  1894.             SA_TraceOut "inc_wsa", "Failed to get ACE object for Admin user " & "(" & Hex(Err.Number) & ")"
  1895.             exit function
  1896.         end if
  1897.  
  1898.         if NOT GetUserAce(objService, strAnonName, strDirRoot, CONST_MODIFYDELTE, objAnonAce ) then
  1899.             SA_TraceOut "inc_wsa", "Failed to get ACE object for Anon user " & "(" & Hex(Err.Number) & ")"
  1900.             exit function
  1901.         end if
  1902.  
  1903.         if bAllowFTP = "true" then
  1904.             if NOT GetUserAce(objService, strFTPName, strDirRoot, CONST_MODIFYDELTE, objFTPAce ) then
  1905.                 SA_TraceOut "inc_wsa", "Failed to get ACE object for Anon user " & "(" & Hex(Err.Number) & ")"
  1906.                 exit function
  1907.             end if
  1908.         end if
  1909.  
  1910.         Set objSecDescriptor = objService.Get("Win32_SecurityDescriptor").SpawnInstance_()
  1911.         if Err.Number <> 0 then
  1912.             SA_TraceOut "inc_wsa", "Failed to get create the Win32_SecurityDescriptor object " & "(" & Hex(Err.Number) & ")"
  1913.             exit function
  1914.         end if
  1915.  
  1916.         objSecDescriptor.Properties_.Item("DACL") = Array()
  1917.         Set objDACL = objSecDescriptor.Properties_.Item("DACL")
  1918.         
  1919.         objDACL.Value(0) = objSiteAdminAce
  1920.         objDACL.Value(1) = objAdminAce    
  1921.         objDACL.Value(2) = objAnonAce
  1922.  
  1923.         if bAllowFTP = "true" then
  1924.             objDACL.Value(3) = objFTPAce
  1925.         end if
  1926.                         
  1927.         objSecDescriptor.Properties_.Item("ControlFlags") = 32772
  1928.         Set objSecDescriptor.Properties_.Item("Owner") = objSiteAdminAce.Trustee
  1929.  
  1930.         Err.Clear
  1931.         
  1932.         retval = objSecSetting.SetSecurityDescriptor( objSecDescriptor )    
  1933.         if Err.number <> 0 then
  1934.             SA_TraceOut "site_new", "Failed to set the Security Descriptor for Root dir " & "(" & Hex(Err.Number) & ")"
  1935.             exit function
  1936.         end if
  1937.                         
  1938.         SA_TraceOut "site_new", "In SetDaclForFtpDir success" 
  1939.  
  1940.         SetDaclForFtpDir = TRUE
  1941.         
  1942.         'Release the objects
  1943.         set objService = nothing
  1944.         set objAdminAce = nothing
  1945.         set objAnonAce = nothing
  1946.         set objAuthAce = nothing
  1947.         set objSecSetting = nothing
  1948.         set objSecDescriptor = nothing
  1949.         
  1950.     End function
  1951.     
  1952.     
  1953.     '-------------------------------------------------------------------------
  1954.     'Function name        :RemoveDaclEntry
  1955.     'Description        :Removes the DACL entry
  1956.     'Input Variables    :strDir, strDirRoot
  1957.     'Output Variables    :None
  1958.     'Returns            :Boolean
  1959.     '-------------------------------------------------------------------------
  1960.     Function RemoveDaclEntry(strDir, strDirRoot)
  1961.         On Error Resume Next
  1962.         Err.Clear
  1963.  
  1964.         RemoveDaclEntry = FALSE
  1965.         
  1966.         Dim objService 
  1967.         Dim objSecSetting        'hold sec setting value
  1968.         Dim objSecDescriptor    'hold security descriptor value
  1969.         Dim strPath        
  1970.         Dim objDACL
  1971.         Dim objSiteAdminAce        'hold admin ace
  1972.         Dim retval                'holds return value            
  1973.         
  1974.         Set objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  1975.         objService.security_.impersonationlevel = 3
  1976.                 
  1977.         'get the sec setting for file
  1978.         strPath = "Win32_LogicalFileSecuritySetting.Path='" & strDir & "'"
  1979.         set objSecSetting = objService.Get(strPath)
  1980.         if Err.number <> 0 then
  1981.             SA_TraceOut "inc_wsa", "Failed to get Sec object for dir " & "(" & Hex(Err.Number) & ")"
  1982.             exit function
  1983.         end if
  1984.  
  1985.         'get the ace's for all req users
  1986.  
  1987.         if NOT GetUserAce(objService, SA_GetAccount_Administrators() , strDirRoot, CONST_FULLCONROL, objSiteAdminAce ) then
  1988.             SA_TraceOut "inc_wsa", "Failed to get ACE object for Administrators " & "(" & Hex(Err.Number) & ")"
  1989.             exit function
  1990.         end if
  1991.  
  1992.  
  1993.         Set objSecDescriptor = objService.Get("Win32_SecurityDescriptor").SpawnInstance_()
  1994.         if Err.Number <> 0 then
  1995.             SA_TraceOut "inc_wsa", "Failed to get create the Win32_SecurityDescriptor object " & "(" & Hex(Err.Number) & ")"
  1996.             exit function
  1997.         end if
  1998.  
  1999.         objSecDescriptor.Properties_.Item("DACL") = Array()
  2000.         Set objDACL = objSecDescriptor.Properties_.Item("DACL")
  2001.         
  2002.         objDACL.Value(0) = objSiteAdminAce        
  2003.                     
  2004.         objSecDescriptor.Properties_.Item("ControlFlags") = 32772
  2005.         Set objSecDescriptor.Properties_.Item("Owner") = objSiteAdminAce.Trustee
  2006.  
  2007.         Err.Clear
  2008.         
  2009.         retval = objSecSetting.SetSecurityDescriptor( objSecDescriptor )    
  2010.         if Err.number <> 0 then
  2011.             SA_TraceOut "site_Delete", "Failed to set the Security Descriptor for Root dir " & "(" & Hex(Err.Number) & ")"
  2012.             exit function
  2013.         end if
  2014.                         
  2015.         SA_TraceOut "site_Delete", "In RemoveDaclEntry success" 
  2016.  
  2017.         RemoveDaclEntry = TRUE
  2018.         
  2019.         'Release the objects
  2020.         set objService = nothing
  2021.         set objSecSetting = nothing
  2022.         set objSecDescriptor = nothing
  2023.         set objSiteAdminAce = nothing
  2024.         
  2025.     End function
  2026.     
  2027.     '-------------------------------------------------------------------------
  2028.     'Function name:            SetExecPerms
  2029.     'Description:            Sets Execute permissions for the web site
  2030.     'Input Variables:        objService, strSiteNum
  2031.     'Returns:                boolean
  2032.     '--------------------------------------------------------------------------
  2033.     Function SetExecPerms(ActiveFormat, objService, strSiteNum)
  2034.         On Error Resume Next
  2035.         Err.Clear
  2036.         
  2037.         Dim strObjPath        'holds objpath value
  2038.         Dim objVirDir        'hold  virtualdirectory path
  2039.  
  2040.         SetExecPerms = FALSE
  2041.         
  2042.         'set application protection
  2043.         strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34) 
  2044.         
  2045.         set objVirDir = objService.Get( strObjPath )
  2046.         
  2047.         If Err.number <> 0 Then
  2048.             SA_TraceOut "inc_wsa", "get vir dir object failed " & Hex(Err.Number)
  2049.             exit Function
  2050.         End if
  2051.         
  2052.         'call the method to set the application Read property        
  2053.         if  ActiveFormat = 2 then
  2054.             objVirDir.AccessExecute = TRUE
  2055.             objVirDir.AccessScript = TRUE
  2056.         elseif  ActiveFormat = 1  then            
  2057.             objVirDir.AccessExecute = FALSE
  2058.             objVirDir.AccessScript = TRUE
  2059.         elseif  ActiveFormat = 0 then            
  2060.             objVirDir.AccessExecute = FALSE
  2061.             objVirDir.AccessScript = FALSE
  2062.         end if
  2063.  
  2064.         objVirDir.put_(WBEMFLAG)
  2065.  
  2066.         if Err.number <> 0 then            
  2067.             SA_TraceOut "Web_ExecutePerms",  "Failed to set exec perms" & "(" & Hex(Err.Number) & ")"
  2068.             exit function
  2069.         end if
  2070.         
  2071.  
  2072.         SetExecPerms = TRUE
  2073.         
  2074.         'Release the object
  2075.         set objVirDir = nothing
  2076.     End Function
  2077.     
  2078.     '------------------------------------------------------------------------------------
  2079.     'Function name        :GetNonInheritedIISSites
  2080.     'Description        :Gets all sites that are not Inheriting settings from the master
  2081.     'Input Variables    :objService,strClassName,strMasterClassName,arrProp
  2082.     'Output Variables    :None
  2083.     'Returns            :Boolean
  2084.     '-------------------------------------------------------------------------------------
  2085.     Function GetNonInheritedIISSites(objService,strClassName,strMasterClassName,arrProp)
  2086.         On Error Resume Next
  2087.         Err.Clear 
  2088.             
  2089.         Dim strQuery            'holds query value
  2090.         Dim objInstances            
  2091.         Dim objInst
  2092.         Dim count
  2093.         Dim strPropCollection
  2094.         Dim arrMasterPropVal
  2095.         Dim strTemp
  2096.         Dim arrWebSites()
  2097.         Dim strManagedSites
  2098.         Dim managedCount    
  2099.         Dim siteCollection
  2100.         Dim Child
  2101.         
  2102.         strQuery = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where ServerID = ServerComment"
  2103.         
  2104.         Set siteCollection = objService.ExecQuery(strQuery)
  2105.  
  2106.         If Err.number  <>  0 or siteCollection.count=0 Then 
  2107.             GetNonInheritedIISSites = 0
  2108.             exit function
  2109.         End If
  2110.         
  2111.         count =0
  2112.         For Each Child In siteCollection
  2113.             redim preserve arrWebSites(count)
  2114.             arrWebSites(count) = Child.Name
  2115.             count = count + 1
  2116.         Next
  2117.  
  2118.         redim arrMasterPropVal(ubound(arrProp))
  2119.                 
  2120.         for count =0 to UBound(arrProp)
  2121.             strPropCollection = strPropCollection & arrProp(count) & ","
  2122.         next
  2123.         
  2124.         strPropCollection = left(strPropCollection,len(strPropCollection)-1)
  2125.         
  2126.         strQuery = "select " & strPropCollection & " from " & strMasterClassName
  2127.         
  2128.         set objInstances = objService.ExecQuery(strQuery)
  2129.                 
  2130.         for each objInst in objInstances
  2131.  
  2132.             for count =  0 to UBound(arrProp)
  2133.                 if  vartype(objInst.Properties_.Item(arrProp(count))) = 11 then    '11 for boolean
  2134.                     'if the property type is boolean, we cannot convert it to a string directly
  2135.                     'string conversion of vbscript is browser preference dependent
  2136.                     'we need to convert boolean to english strings(true/false), otherwise wmi query fails
  2137.                     if objInst.Properties_.Item(arrProp(count)) then
  2138.                         arrMasterPropVal(count) = "'" & "True" & "'"
  2139.                     else
  2140.                         arrMasterPropVal(count) = "'" & "False" & "'"
  2141.                     end if
  2142.                 elseif vartype(objInst.Properties_.Item(arrProp(count))) = 8 then '8 for string
  2143.                     arrMasterPropVal(count) = "'" & objInst.Properties_.Item(arrProp(count)) & "'"
  2144.  
  2145.                 elseif vartype(objInst.Properties_.Item(arrProp(count))) = 3 then '3 for integer
  2146.                     arrMasterPropVal(count) = objInst.Properties_.Item(arrProp(count))
  2147.                 
  2148.                 end if
  2149.             
  2150.             next
  2151.  
  2152.         next
  2153.  
  2154.         'Release objects
  2155.         set objInstances = nothing
  2156.                 
  2157.         for count = 0 to UBound(arrProp)
  2158.             strTemp = strTemp &  arrProp(count)  & " !=" & arrMasterPropVal(count) & " or "
  2159.         next
  2160.     
  2161.         strTemp = left(strTemp,len(strTemp)-3)
  2162.         strTemp = " ( " & strTemp & " ) "
  2163.         
  2164.         for managedCount = 0 to UBound(arrWebSites)
  2165.             if strClassName = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") then 
  2166.                 strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "/Root' and " & strTemp & " or "
  2167.             else
  2168.                 strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "' and " & strTemp & " or "
  2169.             end if
  2170.         next
  2171.         
  2172.         strManagedSites = left(strManagedSites,len(strManagedSites)-3)
  2173.         strQuery = "select * from " & strClassName & " where " & strManagedSites 
  2174.         set objInstances = objService.ExecQuery(strQuery)
  2175.         set GetNonInheritedIISSites = objInstances
  2176.     End Function
  2177.     
  2178.     '------------------------------------------------------------------------------------
  2179.     'Function name        :GetNonInheritedFTPSites
  2180.     'Description        :Gets all sites that are not Inheriting settings from the master
  2181.     'Input Variables    :objService,strClassName,strMasterClassName,arrProp
  2182.     'Output Variables    :None
  2183.     'Returns            :Boolean
  2184.     '-------------------------------------------------------------------------------------
  2185.     Function GetNonInheritedFTPSites(objService,strClassName,strMasterClassName,arrProp)
  2186.         On error Resume Next
  2187.         Err.Clear 
  2188.                 
  2189.         Dim strQuery
  2190.         Dim objInstances
  2191.         Dim objInst
  2192.         Dim count
  2193.         Dim strPropCollection    'holds prop collection
  2194.         Dim arrMasterPropVal
  2195.         Dim strTemp
  2196.         Dim arrWebSites()        'holds array websites collection
  2197.         Dim strManagedSites        'holds managed webites collection
  2198.         Dim managedCount    
  2199.         Dim siteCollection
  2200.         Dim Child
  2201.         
  2202.         strQuery = "select * from " & GetIISWMIProviderClassName("IIs_FTPServerSetting")
  2203.         
  2204.         Set siteCollection = objService.ExecQuery(strQuery)
  2205.  
  2206.         If Err.number  <>  0 or siteCollection.count=0 Then 
  2207.             GetNonInheritedFTPSites = 0
  2208.             exit function
  2209.         End If
  2210.         
  2211.         count =0
  2212.         For Each Child In siteCollection
  2213.             redim preserve arrWebSites(count)
  2214.             arrWebSites(count) = Child.Name
  2215.             count = count + 1
  2216.         Next
  2217.  
  2218.         redim arrMasterPropVal(ubound(arrProp))
  2219.                 
  2220.         for count =0 to UBound(arrProp)
  2221.             strPropCollection = strPropCollection & arrProp(count) & ","
  2222.         next
  2223.         
  2224.         strPropCollection = left(strPropCollection,len(strPropCollection)-1)
  2225.         strQuery = "select " & strPropCollection & " from " & strMasterClassName
  2226.         set objInstances = objService.ExecQuery(strQuery)
  2227.             
  2228.         for each objInst in objInstances
  2229.             for count =  0 to UBound(arrProp)
  2230.                 if  vartype(objInst.Properties_.Item(arrProp(count))) = 11 then    '11 for boolean
  2231.                     'if the property type is boolean, we cannot convert it to a string directly
  2232.                     'string conversion of vbscript is browser preference dependent
  2233.                     'we need to convert boolean to english strings(true/false), otherwise wmi query fails
  2234.                     if objInst.Properties_.Item(arrProp(count)) then
  2235.                         arrMasterPropVal(count) = "'" & "True" & "'"
  2236.                     else
  2237.                         arrMasterPropVal(count) = "'" & "False" & "'"
  2238.                     end if
  2239.                 elseif vartype(objInst.Properties_.Item(arrProp(count))) = 8 then '8 for string
  2240.                     arrMasterPropVal(count) = "'" & objInst.Properties_.Item(arrProp(count)) & "'"
  2241.                 elseif vartype(objInst.Properties_.Item(arrProp(count))) = 3 then '3 for integer
  2242.                     arrMasterPropVal(count) = objInst.Properties_.Item(arrProp(count))
  2243.                 end if
  2244.             next
  2245.         next
  2246.  
  2247.         'Release objects
  2248.         set objInstances = nothing
  2249.         
  2250.         for count = 0 to UBound(arrProp)
  2251.             ' Must handle null values in the WMI master service object to prevent invalid
  2252.             ' queries from causing errors even when non-inherited sites existed.
  2253.             if (not IsNull(arrMasterPropVal(count))) then
  2254.                 strTemp = strTemp &  arrProp(count)  & " !=" & arrMasterPropVal(count) & " or "
  2255.             else
  2256.                 strTemp = strTemp &  arrProp(count)  & " IS NOT NULL or "
  2257.             end if
  2258.         next
  2259.         strTemp = left(strTemp,len(strTemp)-3)
  2260.         strTemp = " ( " & strTemp & " ) "
  2261.         for managedCount = 0 to UBound(arrWebSites)
  2262.             if strClassName = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") then 
  2263.                 strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "/Root' and " & strTemp & " or "
  2264.             else
  2265.                 strManagedSites = strManagedSites & " Name = '" & arrWebSites(managedCount) & "' and " & strTemp & " or "
  2266.             end if
  2267.         next
  2268.         
  2269.         strManagedSites = left(strManagedSites,len(strManagedSites)-3)
  2270.         strQuery = "select * from " & strClassName & " where " & strManagedSites 
  2271.     
  2272.         ' "WQL" and 0 parameters used to get error information immediately rather than
  2273.         ' when first accessing the results.
  2274.         set objInstances = objService.ExecQuery(strQuery, "WQL", 0)
  2275.         set GetNonInheritedFTPSites = objInstances
  2276.     End Function
  2277.  
  2278.     '------------------------------------------------------------------------------------
  2279.     'Function name        :GetDomainName
  2280.     'Description        :Function to get the domain name
  2281.     'Input Variables    :none
  2282.     'Output Variables    :None
  2283.     'Returns        :String -domain name
  2284.     '-------------------------------------------------------------------------------------
  2285.     Function GetDomainName
  2286.         Err.clear
  2287.         On Error Resume Next
  2288.     
  2289.         Dim objSystem 
  2290.  
  2291.         Set objSystem = CreateObject("WinntSystemInfo")        
  2292.         GetDomainName = objSystem.domainname
  2293.         
  2294.         'Checking for the error condition
  2295.         If Err.number <> 0 then
  2296.             GetDomainName = ""
  2297.         end IF
  2298.     End function
  2299.  
  2300.     '-------------------------------------------------------------------------
  2301.     'Function name        :SetWebDefaultPage
  2302.     'Description        :set the default page of web
  2303.     'Input Variables    :strDefaultPage
  2304.     'Output Variables    :None
  2305.     'Returns            :Boolean
  2306.     'Global Variables    :None
  2307.     '-------------------------------------------------------------------------
  2308.     Function SetWebDefaultPage(objService,strDefaultPage,strSiteNum)
  2309.         On Error Resume Next
  2310.         Err.Clear
  2311.         
  2312.         Dim strObjPath
  2313.         Dim objWebSite
  2314.         
  2315.         SetWebDefaultPage = False
  2316.  
  2317.         strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)
  2318.         Set objWebSite = objService.Get(strObjPath)
  2319.  
  2320.         If Err.number <> 0 Then
  2321.             SA_TraceOut "site_new", "Failed to get the IIs_WebServer Object with error " & strObjPath
  2322.             Exit Function
  2323.         End if
  2324.  
  2325.         objWebSite.DefaultDoc = strDefaultPage
  2326.         objWebSite.put_(WBEMFLAG)
  2327.  
  2328.         If Err.number <> 0 Then            
  2329.             SA_TraceOut "inc_wsa",  "Failed to set default Page"
  2330.             Set objWebSite = Nothing
  2331.             Exit Function
  2332.         End If
  2333.  
  2334.         SetWebDefaultPage = True
  2335.         Set objWebSite = Nothing
  2336.     End Function
  2337.  
  2338.     '-------------------------------------------------------------------------
  2339.     'Function name        :GetWebDefaultPage
  2340.     'Description        :get the default page of web
  2341.     'Input Variables    :strDefaultPage
  2342.     'Output Variables    :None
  2343.     'Returns            :Boolean
  2344.     'Global Variables    :None
  2345.     '-------------------------------------------------------------------------
  2346.     Function GetWebDefaultPage(objService,strDefaultPage,strSiteNum)
  2347.         On Error Resume Next
  2348.         Err.Clear
  2349.         
  2350.         Dim strObjPath
  2351.         Dim objWebSite
  2352.         
  2353.         GetWebDefaultPage = ""
  2354.  
  2355.         strObjPath = GetIISWMIProviderClassName("IIs_WebVirtualDirSetting") & ".Name=" & chr(34) & strSiteNum & "/ROOT" & chr(34)
  2356.         Set objWebSite = objService.Get(strObjPath)
  2357.         
  2358.         If Err.number <> 0 Then
  2359.             SA_TraceOut "site_new", "Failed to get the IIs_WebServer Object with error " & strObjPath
  2360.             Exit Function
  2361.         End if
  2362.         
  2363.         GetWebDefaultPage = objWebSite.DefaultDoc
  2364.  
  2365.         If Err.number <> 0 Then    
  2366.             SA_TraceOut "inc_wsa",  "Failed to get default Page"
  2367.             Set objWebSite = Nothing
  2368.             Exit Function
  2369.         End If
  2370.  
  2371.         Set objWebSite = Nothing
  2372.     End Function
  2373.  
  2374.     '-------------------------------------------------------------------------
  2375.     'Function name        :UpdateFrontPage
  2376.     'Description        :updates the frontpage extensions
  2377.     'Input Variables    :strSiteName
  2378.     'Output Variables    :None
  2379.     'Returns            :Boolean
  2380.     'Global Variables    :None
  2381.     '-------------------------------------------------------------------------
  2382.     Function UpdateFrontPage(bUpdateFront, strSiteName, strUserName)
  2383.         On Error Resume Next
  2384.         Err.Clear
  2385.  
  2386.         '
  2387.         ' Default return value is success (TRUE)
  2388.         UpdateFrontPage = TRUE
  2389.         
  2390.         if (bUpdateFront = TRUE OR Trim(UCase(bUpdateFront)) = "TRUE") then
  2391.         
  2392.             UpdateFrontPage = InstallFrontPageWeb(strSiteName, strUserName)
  2393.             
  2394.         elseif (bUpdateFront = FALSE OR Trim(UCase(bUpdateFront)) = "FALSE") then
  2395.         
  2396.             UpdateFrontPage = UnInstallFrontPageWeb(strSiteName)
  2397.  
  2398.         else
  2399.             Call SA_TraceOut("INC_WSA", "Function UpdateFrontPage: Invalid argument bUpdateFront=(" & bUpdateFront & ")")
  2400.         end if
  2401.         
  2402.     End function
  2403.  
  2404.     '----------------------------------------------------------------------------
  2405.     'Function name        :GetBindings
  2406.     'Description        :Serves in Getting the data in the form of "ipaddress:tcpport:hostheader"
  2407.     'Input Variables    :TCP/IP,PORT,HOST HEADER 
  2408.     'Output Variables    :None
  2409.     'Returns            :Bindings 
  2410.     'Global Variables    :None    
  2411.     '----------------------------------------------------------------------------
  2412.     function GetBindings (tempip, temptcp, temphost )
  2413.         Err.Clear
  2414.         On Error Resume Next
  2415.  
  2416.         Dim retval        ' To hold the return value
  2417.         ' if tcpport not specified set default to 80
  2418.         if trim(temptcp)= "" then
  2419.             temptcp = "80" 
  2420.         end if
  2421.             
  2422.         ' return in the form "ipaddress:tcpport:hostheader"
  2423.         if isempty(tempip) = false then
  2424.             retval = tempip & ":" & temptcp & ":"
  2425.         else
  2426.             retval =  ":" & temptcp & ":"
  2427.         end if
  2428.         if  isempty(temphost) = false then
  2429.             retval = retval & temphost
  2430.         end if
  2431.         GetBindings = retval
  2432.     end function
  2433.  
  2434.     '----------------------------------------------------------------------------
  2435.     'Function name        :GetWebAdministrtorRole
  2436.     'Description        :used to get the web adminitrator role
  2437.     'Input Variables    :TCP/IP,PORT,HOST HEADER 
  2438.     'Output Variables    :None
  2439.     'Returns            :"Domain user" or "localuser"
  2440.     'Global Variables    :None
  2441.     '----------------------------------------------------------------------------
  2442.  
  2443.     Function GetWebAdministrtorRole(objService, strSiteNum, ByRef strAdminName)
  2444.         On Error Resume Next
  2445.         Err.Clear
  2446.  
  2447.         Dim strQuery
  2448.         Dim objAdminColection
  2449.         Dim inst
  2450.         Dim strAdminRole
  2451.         Dim arrField
  2452.         Dim strSysName
  2453.         Dim strDirectoryRoot
  2454.  
  2455.         GetWebAdministrtorRole = ""
  2456.         strAdminName = ""
  2457.  
  2458.         strQuery = "select * from " & GetIISWMIProviderClassName("IIs_ACE") &  " where name = "& _
  2459.                 chr(34)&strSiteNum&chr(34)
  2460.  
  2461.         Set objAdminColection = objService.ExecQuery(strQuery)
  2462.         If Err.number <> 0 Then    
  2463.             SA_TraceOut "Failed to get web Administrator" 
  2464.             exit Function
  2465.         End if
  2466.  
  2467.         For each inst in objAdminColection
  2468.             If inst.AccessMask = 11 Then
  2469.                 strAdminName = inst.Trustee
  2470.                 Exit For
  2471.             End If
  2472.         Next
  2473.  
  2474.         If strAdminName = "" Then
  2475.             Exit Function
  2476.         End If
  2477.         
  2478.         arrField = split(strAdminName,"\")
  2479.  
  2480.         If ubound(arrField) <> 1 Then
  2481.             Exit Function
  2482.         End If
  2483.  
  2484.         strAdminRole = ucase(arrField(0))
  2485.  
  2486.         Call GetDomainRole(strDirectoryRoot, strSysName)
  2487.  
  2488.         If strAdminRole = ucase(strSysName) Then
  2489.             GetWebAdministrtorRole = "Local User"
  2490.         Else
  2491.             GetWebAdministrtorRole = "Domain User"
  2492.         End If
  2493.  
  2494.         Set objAdminColection = nothing
  2495.         Set inst = nothing
  2496.     End Function
  2497.  
  2498.     '----------------------------------------------------------------------------
  2499.     'Function name        :CreateVirFTPSite
  2500.     'Description        :Serves in create virtual ftp site
  2501.     'Input Variables    :None 
  2502.     'Output Variables    :None
  2503.     'Returns            :Boolean (True if new site is created else returns False)
  2504.     'Global Variables    :None
  2505.     'Functions Used        :
  2506.     '----------------------------------------------------------------------------
  2507.     Function CreateVirFTPSite(objService, user, path, bRead, bWrite, bLog)
  2508.         On Error Resume Next
  2509.         Err.Clear
  2510.  
  2511.         Dim objVirFTP
  2512.         Dim strUser
  2513.  
  2514.         CreateVirFTPSite = False
  2515.         Set objVirFTP = objService.Get(GetIISWMIProviderClassName("IIs_FtpVirtualDirSetting")).SpawnInstance_
  2516.         If Err.number <> 0 Then
  2517.             Call SA_TraceOut("inc_wsa", "Failed to get new Instance of "& _
  2518.                 "IIs_FtpVirtualDirSetting " & "(" & Hex(Err.Number) & ")")
  2519.             Exit Function
  2520.         End If
  2521.  
  2522.         '
  2523.         ' objVirFTP.put_(WBEMFLAG) will silently fail (Err variable will not be set correctly)
  2524.         ' if we use a user name that has the form <DomainName>\<UserName>.
  2525.         ' So we remove the <DomainName>, if it is part of the user name
  2526.         '
  2527.         If ( InStr(F_strAdminName, "\") <> 0 ) Then
  2528.             Dim arrId
  2529.  
  2530.             arrId = split(F_strAdminName,"\")
  2531.             strUser = arrId(1)
  2532.         Else
  2533.             strUser = F_strAdminName
  2534.         End If
  2535.  
  2536.  
  2537.         objVirFTP.Name = GetAdminFTPServerName() & "/ROOT/"& strUser
  2538.         objVirFTP.Path = path
  2539.         objVirFTP.AccessRead = bRead
  2540.         objVirFTP.AccessWrite = bWrite
  2541.         objVirFTP.DontLog = NOT bLog
  2542.  
  2543.         objVirFTP.put_(WBEMFLAG)
  2544.  
  2545.         If Err.number <> 0 Then
  2546.             Call SA_TraceOut("inc_wsa", "Failed to Create FTP site "& _
  2547.                  "(" & Hex(Err.Number) & ")")
  2548.             Exit Function
  2549.         End If
  2550.  
  2551.         Set objVirFTP = Nothing
  2552.         CreateVirFTPSite = True
  2553.     End Function    
  2554.  
  2555.     '----------------------------------------------------------------------------
  2556.     'Function name        :DeleteVirFTPSite
  2557.     'Description        :Serves in delete virtual ftp site
  2558.     'Input Variables    :None 
  2559.     'Output Variables    :None
  2560.     'Returns            :Boolean (True if new site is created else returns False)
  2561.     'Global Variables    :None
  2562.     'Functions Used        :
  2563.     '----------------------------------------------------------------------------
  2564.     Function DeleteVirFTPSite(objService, user)
  2565.         On Error Resume Next
  2566.         Err.Clear
  2567.  
  2568.         Dim strObjPath        'holds site collection
  2569.         Dim objVirFTPSite        'holds instance of the site
  2570.  
  2571.         DeleteVirFTPSite = False
  2572.  
  2573.         strObjPath = GetIISWMIProviderClassName("IIs_FtpVirtualDirSetting") & ".Name=" & chr(34) & GetAdminFTPServerName() & "/ROOT/"&user & chr(34)
  2574.         Set objVirFTPSite = objService.Get(strObjPath)
  2575.         If Err.Number <> 0 Then
  2576.             Call SA_TraceOut("inc_wsa","Unable to get the virtual ftp site object ")
  2577.             Exit Function
  2578.         End If
  2579.  
  2580.         'delete the object
  2581.         objVirFTPSite.Delete_
  2582.         if Err.Number <> 0 then
  2583.             SA_TraceOut "inc_wsa", "Unable to delete the virtual ftp site "
  2584.             Exit Function
  2585.         End If
  2586.  
  2587.         DeleteVirFTPSite = True
  2588.  
  2589.         'Release the object
  2590.         set objVirFTPSite = nothing
  2591.     End Function
  2592.  
  2593.     '----------------------------------------------------------------------------
  2594.     'Function name        :IsUserVirFTPInstalled
  2595.     'Description        :Serves in determin that user vir FTP Installed
  2596.     'Input Variables    :None 
  2597.     'Output Variables    :None
  2598.     'Returns            :Boolean (True if new site is created else returns False)
  2599.     'Global Variables    :None
  2600.     'Functions Used        :
  2601.     '----------------------------------------------------------------------------
  2602.     Function IsUserVirFTPInstalled(objService, user)
  2603.         On Error Resume Next
  2604.         Err.Clear
  2605.  
  2606.         Dim strQuery                'holds query string
  2607.         Dim objVirFTPSiteCollect    'holds site collection
  2608.  
  2609.         IsUserVirFTPInstalled = False
  2610.  
  2611.         
  2612.         'strQuery = "Select * from " & GetIISWMIProviderClassName("IIs_FtpVirtualDirSetting") & " where Name="&chr(34)&"MSFTPSVC/1/ROOT/"&user&chr(34)
  2613.         strQuery = "Select * from " & GetIISWMIProviderClassName("IIs_FtpVirtualDirSetting") & " where Name="&chr(34)& GetAdminFTPServerName() & "/ROOT/"&user&chr(34)
  2614.         Set objVirFTPSiteCollect = objService.ExecQuery(strQuery)
  2615.         
  2616.         If Err.Number <> 0 or objVirFTPSiteCollect.count=0 Then
  2617.             set objVirFTPSiteCollect = nothing
  2618.             Exit Function
  2619.         End If
  2620.  
  2621.         IsUserVirFTPInstalled = True
  2622.  
  2623.         'Release the object
  2624.         set objVirFTPSiteCollect = nothing
  2625.     End Function
  2626.  
  2627.     '----------------------------------------------------------------------------
  2628.     'Function name        :IsFTPServiceInstalled
  2629.     'Description        :Serves in wheather the FTP service be installed
  2630.     'Input Variables    :None 
  2631.     'Output Variables    :None
  2632.     'Returns            :Boolean (True if new site is created else returns False)
  2633.     'Global Variables    :None
  2634.     'Functions Used        :
  2635.     '----------------------------------------------------------------------------
  2636.     Function IsFTPServiceInstalled(objService)
  2637.         On Error Resume Next
  2638.         Err.Clear
  2639.  
  2640.         Dim ObjCollection
  2641.         Dim objInst
  2642.  
  2643.         IsFTPServiceInstalled = False
  2644.  
  2645.         Set ObjCollection = objService.Instancesof(GetIISWMIProviderClassName("IIs_FtpServiceSetting"))
  2646.         If Err.number <>0 then
  2647.             Call SA_TRACEOUT("IsFTPServiceInstalled","Failed to get service")
  2648.             Exit Function
  2649.         end if
  2650.         
  2651.         For Each objInst In ObjCollection
  2652.             If ucase(objService.name) = "objInst" Then
  2653.                 IsFTPServiceInstalled = True
  2654.                 Exit Function
  2655.             End If
  2656.         Next
  2657.  
  2658.         Set ObjCollection = Nothing
  2659.         Set objInst = Nothing
  2660.     End Function
  2661.  
  2662.     '----------------------------------------------------------------------------
  2663.     'Function name        :IsValidWebPort(strSiteID,strPort)
  2664.     'Description        :Used to determin wheather the web port is valid
  2665.     'Input Variables    :None 
  2666.     'Output Variables    :None
  2667.     'Returns            :Boolean (True for valid web port)
  2668.     'Global Variables    :None
  2669.     'Functions Used        :
  2670.     '----------------------------------------------------------------------------
  2671.     Function IsValidWebPort(strSiteID, strPort)
  2672.         On Error Resume Next
  2673.         Err.Clear
  2674.  
  2675.         Dim objService
  2676.         Dim objCollection
  2677.         Dim objSite
  2678.         Dim arrBindings
  2679.         Dim strTmp
  2680.  
  2681.  
  2682.         IsValidWebPort = True
  2683.         If  strPort = "" Then
  2684.             strPort = "80"
  2685.         End If
  2686.         Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  2687.         If Err.Number <> 0 Then
  2688.             Call SA_TRACEOUT("inc_wsa","Faild to connect WMI object")
  2689.         End If
  2690.         Set ObjCollection = objService.Instancesof(GetIISWMIProviderClassName("IIs_WebServerSetting"))
  2691.         For Each objSite In ObjCollection
  2692.  
  2693.             'Check to see if iis6.0 wmi provider is intalled        
  2694.             If IsIIS60Installed Then
  2695.                 strTmp = objSite.ServerBindings(0).Port        
  2696.             Else
  2697.  
  2698.             arrBindings = Split(objSite.ServerBindings(0),":")
  2699.             strTmp = arrBindings(1)
  2700.             End If
  2701.             
  2702.             If strPort = strTmp Then
  2703.  
  2704.  
  2705.                 Call SA_TRACEOUT("IsValidWebPort", "strSiteID="&strSiteID)
  2706.                 Call SA_TRACEOUT("IsValidWebPort", "objSite.ServerID="&objSite.ServerID)
  2707.                 If CStr(objSite.ServerID) <> strSiteID Then
  2708.                     IsValidWebPort = False
  2709.                     Exit Function
  2710.                 End If
  2711.             End If
  2712.         Next
  2713.  
  2714.         Set objSite = Nothing
  2715.         Set ObjCollection = Nothing
  2716.         Set objService = Nothing
  2717.  
  2718.     End Function
  2719.  
  2720.     '
  2721.     ' The following two function is very useful to set the permissiton to 
  2722.     ' directory, when set the web root permission, we call these function
  2723.     '
  2724.     '-------------------------------------------------------------------------
  2725.     'Function name:            GetUserAce
  2726.     'Description:            Get the ACLs of the user
  2727.     'Input Variables:        objService, strUserName, strDomain, nAccessMask, ByRef objACE
  2728.     'Returns:                boolean
  2729.     '--------------------------------------------------------------------------
  2730.     Function GetUserAce(objService, strUserName, strDomain, nAccessMask, ByRef objACE)
  2731.         On Error Resume Next
  2732.         Err.Clear 
  2733.         
  2734.         Dim strObjPath    'holds query string
  2735.         Dim objAcct        'holds query result
  2736.         Dim objSID        'holds security identifier    
  2737.         Dim objTrustee    'holds trustee value
  2738.         
  2739.         GetUserAce = FALSE
  2740.                 
  2741.         strObjPath = "Win32_UserAccount.Domain=" & chr(34) & strDomain & chr(34) & ",Name=" & chr(34) & strUserName & chr(34)
  2742.         
  2743.         set objAcct = objService.Get(strObjPath)
  2744.         if Err.number <> 0 then
  2745.             SA_TraceOut "inc_wsa", "Failed to get Win32_UserAccount Object " & "(" & Hex(Err.Number) & ")" 
  2746.             exit function
  2747.         end if
  2748.         
  2749.         set objSID = objService.Get("Win32_SID.SID='" & objAcct.SID & "'")
  2750.         if Err.number <> 0 then
  2751.             SA_TraceOut "inc_wsa", "Failed to get Win32_SID Object " & "(" & Hex(Err.Number) & ")" 
  2752.             exit function
  2753.         end if
  2754.     
  2755.         set objTrustee = objService.Get("Win32_Trustee").SpawnInstance_
  2756.         if Err.number <> 0 then
  2757.             SA_TraceOut "inc_wsa", "Failed to get new Instance of Win32_Trustee " & "(" & Hex(Err.Number) & ")" 
  2758.             exit function
  2759.         end if
  2760.                         
  2761.         objTrustee.Name = strUserName
  2762.         objTrustee.Domain = strDomain
  2763.         objTrustee.SID = objSID.BinaryRepresentation
  2764.         objTrustee.SIDString = objSID.SID
  2765.         objTrustee.SidLength = objSID.SidLength
  2766.         set objACE = objService.Get("Win32_ACE").SpawnInstance_        
  2767.         if Err.number <> 0 then
  2768.             SA_TraceOut "inc_wsa", "Failed to Create Win32_Ace Object " & "(" & Hex(Err.Number) & ")" 
  2769.             exit function
  2770.         end if
  2771.  
  2772.         objACE.AccessMask =  nAccessMask
  2773.         objACE.Aceflags = 3
  2774.         objACE.AceType = 0
  2775.         objACE.Trustee = objTrustee
  2776.         SA_TraceOut "inc_wsa", "In GetUserAce function success" 
  2777.         GetUserAce = TRUE
  2778.             
  2779.         'Release objects
  2780.         set objAcct =  nothing
  2781.         set objSID = nothing
  2782.         set objTrustee = nothing
  2783.     End Function
  2784.  
  2785.     '-------------------------------------------------------------------------
  2786.     'Function name:            GetGroupAce
  2787.     'Description:            Get the ACLs of the group
  2788.     'Input Variables:        objService, strGroupName, strDomain, nAccessMask, ByRef objACE
  2789.     'Returns:                boolean
  2790.     '--------------------------------------------------------------------------
  2791.     Function GetGroupAce(objService, strGroupName, strDomain, nAccessMask, ByRef objACE)
  2792.         On Error Resume Next
  2793.         Err.Clear 
  2794.         
  2795.         Dim strObjPath    'holds query string
  2796.         Dim objAcct        'holds query result
  2797.         Dim objSID        'holds security identifier    
  2798.         Dim objTrustee    'holds trustee value
  2799.         
  2800.         GetGroupAce = FALSE
  2801.                 
  2802.         strObjPath = "Win32_Group.Domain=" & chr(34) & strDomain & chr(34) & ",Name=" & chr(34) & strGroupName & chr(34)
  2803.         
  2804.         set objAcct = objService.Get(strObjPath)
  2805.         if Err.number <> 0 then
  2806.             Call SA_TraceOut("inc_wsa", "Get Win32_Group failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  2807.             Call SA_TraceOut("inc_wsa", "-->Object path: " + CStr(strObjPath) )
  2808.             exit function
  2809.         end if
  2810.         
  2811.         set objSID = objService.Get("Win32_SID.SID='" & objAcct.SID & "'")
  2812.         if Err.number <> 0 then
  2813.             SA_TraceOut "inc_wsa", "Failed to get Win32_SID Object " & "(" & Hex(Err.Number) & ")" 
  2814.             exit function
  2815.         end if
  2816.  
  2817.         set objTrustee = objService.Get("Win32_Trustee").SpawnInstance_
  2818.         if Err.number <> 0 then
  2819.             SA_TraceOut "inc_wsa", "Failed to get new Instance of Win32_Trustee " & "(" & Hex(Err.Number) & ")" 
  2820.             exit function
  2821.         end if
  2822.                         
  2823.         objTrustee.Name = strGroupName
  2824.         objTrustee.Domain = strDomain
  2825.         objTrustee.SID = objSID.BinaryRepresentation
  2826.         objTrustee.SIDString = objSID.SID
  2827.         objTrustee.SidLength = objSID.SidLength
  2828.         set objACE = objService.Get("Win32_ACE").SpawnInstance_        
  2829.         if Err.number <> 0 then
  2830.             SA_TraceOut "inc_wsa", "Failed to Create Win32_Ace Object " & "(" & Hex(Err.Number) & ")" 
  2831.             exit function
  2832.         end if
  2833.  
  2834.         objACE.AccessMask =  nAccessMask
  2835.         objACE.Aceflags = 3
  2836.         objACE.AceType = 0
  2837.         objACE.Trustee = objTrustee
  2838.         SA_TraceOut "inc_wsa", "In GetGroupAce function success" 
  2839.         GetGroupAce = TRUE
  2840.  
  2841.         'Release objects
  2842.         set objAcct =  nothing
  2843.         set objSID = nothing
  2844.         set objTrustee = nothing
  2845.     End Function
  2846.  
  2847.     '-------------------------------------------------------------------------
  2848.     'Function name        :ModifyUserInOu
  2849.     'Description        :Modify User settings in OU 
  2850.     '                    group
  2851.     'Input Variables    :strUserName,strOuName, strGrpName
  2852.     'Output Variables    :None
  2853.     'Returns            :Boolean
  2854.     'Global Variables    :None    
  2855.     '-------------------------------------------------------------------------
  2856.     Function ModifyUserInOu(strSiteID,strDomain,strUserName, strPassword, strGrpName)
  2857.         On Error Resume Next
  2858.         Err.Clear
  2859.             
  2860.         Dim oUser                'holds user object
  2861.         Dim objComputer            'holds computer object
  2862.  
  2863.         ModifyUserInOu = false
  2864.  
  2865.         SA_TraceOut "inc_wsa.asp", "In ModifyUserInOu"
  2866.  
  2867.         Set objComputer = GetObject("WinNT://" & strDomain)        
  2868.         Set oUser = objComputer.GetObject("user" , trim(strUserName))
  2869.         If Err.number <> 0 Then
  2870.             SA_TraceOut "inc_wsa.asp", "In ModifyUserInOu, get user pswd failed "
  2871.             SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  2872.                                 Array("user " & trim(strUserName)))
  2873.             Exit Function
  2874.         End if        
  2875.         
  2876.         oUser.setPassword(trim(strPassword))
  2877.         oUser.SetInfo()        
  2878.         if Err.number <> 0  then
  2879.             mintTabSelected = 0    
  2880.             If Err.number = &H800708C5 Then
  2881.                 SetErrMsg L_ERR_PASSWORD_POLICY
  2882.             Else
  2883.                 SetErrMsg L_SETPW_ERRORMESSAGE
  2884.             End If
  2885.             exit Function
  2886.         end if
  2887.  
  2888.         SA_TraceOut "inc_wsa.asp", "In ModifyUserInOu successfull"
  2889.  
  2890.         'release objects
  2891.         set oUser = nothing        
  2892.         set objComputer = nothing
  2893.  
  2894.         ModifyUserInOu = true
  2895.     End function
  2896.  
  2897.     '-------------------------------------------------------------------------
  2898.     'Function name        :GetRandomPassword
  2899.     'Description        :Generates a random password
  2900.     'Input Variables    :None
  2901.     'Output Variables    :strPassword
  2902.     'Returns            :string
  2903.     'Global Variables    :None    
  2904.     '-------------------------------------------------------------------------
  2905.  
  2906.     Function GetRandomPassword
  2907.  
  2908.         On Error Resume Next
  2909.         Err.Clear
  2910.             
  2911.  
  2912.         GetRandomPassword = ""
  2913.  
  2914.         Dim objSAHelper
  2915.         Dim strPassword
  2916.  
  2917.         Set objSAHelper = server.CreateObject("ServerAppliance.SAHelper")
  2918.         
  2919.         if Err.number <> 0 then
  2920.             Call SA_TraceOut ("inc_wsa", "createobject for sahelper failed")
  2921.             exit function
  2922.         else
  2923.             strPassword = objSAHelper.GenerateRandomPassword(14)
  2924.             if Err.number <> 0 then
  2925.                 Call SA_TraceOut ("inc_wsa", "generate random password failed")
  2926.                 Set objSAHelper = Nothing
  2927.                 exit function
  2928.             end if
  2929.         end if            
  2930.  
  2931.         GetRandomPassword = strPassword
  2932.  
  2933.     End Function
  2934.  
  2935.  
  2936.     '-------------------------------------------------------------------------
  2937.     'Function name        :SetPasswdInAD
  2938.     'Description        :Create Users in OU and adds the user to specified 
  2939.     '                    group
  2940.     'Input Variables    :strUserName,strOuName
  2941.     'Output Variables    :None
  2942.     'Returns            :Boolean
  2943.     'Global Variables    :None    
  2944.     '-------------------------------------------------------------------------
  2945.     Function SetPasswdInAD(strSiteID,strUserName, strPassword)
  2946.         On Error Resume Next
  2947.         Err.Clear
  2948.             
  2949.         Dim oUser                'holds user object
  2950.         Dim oRoot                'holds root object
  2951.         Dim oOUWebSites            'holds OU website 
  2952.         Dim oOUSiteID            'holds OU siteid
  2953.     
  2954.  
  2955.         SetPasswdInAD = False
  2956.  
  2957.         SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD"
  2958.  
  2959.         SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD strSiteID: " + strSiteID 
  2960.         SA_traceOut "G_strDirRoot: " , G_strDirRoot
  2961.  
  2962.         Set oRoot = GetObject("LDAP://" & G_strDirRoot)
  2963.         If Err.number <> 0 Then
  2964.             SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  2965.                                 Array("LDAP://" & G_strDirRoot))
  2966.             SA_TraceOut "inc_wsa.asp", "Connect to LDAP failed"
  2967.             Exit Function
  2968.         End if            
  2969.             
  2970.         Set oOUWebSites = oRoot.GetObject("organizationalUnit", "ou=WebSites")
  2971.         If err.number <> 0 Then 
  2972.             SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  2973.                                 Array("WebSites organizational unit"))
  2974.             SA_TraceOut "inc_wsa.asp", _
  2975.                 "In SetPasswdInAD, get ou web sites failed"
  2976.             Exit Function
  2977.         End If
  2978.         
  2979.         Set oOUSiteID = oOUWebSites.GetObject("organizationalUnit", "ou=" & strSiteID)
  2980.         If err.number<>0 Then
  2981.             SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  2982.                                 Array(strSiteID & " organizational unit"))
  2983.             SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD, get ou siteid failed"
  2984.             Exit Function
  2985.         End If                
  2986.  
  2987.         SA_traceout "strUserName: ", strUserName
  2988.  
  2989.         Set oUser = oOUSiteID.GetObject("User", "cn=" + strUserName )            
  2990.         If Err.number <> 0 Then
  2991.             SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD, GetObject user failed "
  2992.             SetErrMsg L_CREATEUSER_ERRORMESSAGE
  2993.             Exit Function
  2994.         End If
  2995.  
  2996.  
  2997.         oUser.setPassword(strPassword)
  2998.         If Err.number <> 0 Then
  2999.             SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD, SetPassword ** failed ** "
  3000.             SetErrMsg L_CREATEUSER_ERRORMESSAGE
  3001.             Exit Function
  3002.         End If
  3003.  
  3004.         oUser.SetInfo()
  3005.         if Err.number <> 0 then
  3006.             SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD, SetInfo failed "
  3007.             SetErrMsg L_CREATEUSER_ERRORMESSAGE
  3008.             Exit Function
  3009.         end if
  3010.             
  3011.  
  3012.         SA_TraceOut "inc_wsa.asp", "In SetPasswdInAD successfull"
  3013.  
  3014.         'release objects
  3015.         Set oUser        = nothing        
  3016.         Set oOUWebSites = nothing
  3017.         Set oOUSiteID    = nothing
  3018.         Set oRoot        = nothing
  3019.     
  3020.         
  3021.         SetPasswdInAD = true
  3022.  
  3023.     End function
  3024.  
  3025.     '-------------------------------------------------------------------------
  3026.     'Function name        :SetPasswdInNT
  3027.     'Description        :Set password in NT
  3028.     'Input Variables    :strUserName -- username to set the password for
  3029.     'Input Variables    :strPassword -- password to be used
  3030.     'Returns            :True or False
  3031.     'Global Variables    :None    
  3032.     '-------------------------------------------------------------------------
  3033.  
  3034.     Function SetPasswdInNT(  strDomainName, strUserName, strPassword )
  3035.         On Error Resume Next
  3036.         Err.Clear
  3037.  
  3038.         Dim objComputer
  3039.         Dim objUser
  3040.  
  3041.         SetPasswdInNT = False
  3042.  
  3043.         SA_TraceOut "inc_wsa.asp", "In SetPasswdInNT"
  3044.  
  3045.         SA_TraceOut "strDomainName:", strDomainName
  3046.         'SA_TraceOut "G_strSysName:", G_strSysName
  3047.         Set objComputer = GetObject("WinNT://" & strDomainName)
  3048.         If Err.number <> 0 Then
  3049.             SA_TraceOut "inc_wsa", "failed to GetObject in SetPasswdinNT : G_strSysName: " + G_strSysName
  3050.             SetErrMsg SA_GetLocString("Sitearea.dll", "C04201D4", _
  3051.                                 Array("WinNT://" & strDomain))
  3052.             Exit Function
  3053.         End if
  3054.  
  3055.         Set objUser = objComputer.GetObject("User" , strUserName)
  3056.         If Err.number <> 0 Then
  3057.             SA_TraceOut "inc_wsa", "failed to GetObject in SetPasswdinNT : strUserName: " + strUserName                    
  3058.             SetErrmsg L_ERR_GET_USER_OBJECT
  3059.             Exit Function
  3060.         End If
  3061.  
  3062.         objUser.setPassword(trim(strPassword))
  3063.         objUser.SetInfo()
  3064.  
  3065.         If Err.number <> 0 Then
  3066.             SA_TraceOut "inc_wsa", "failed to SetInfo in SetPasswdinNT : strPassword: " + strPassword                    
  3067.             If Err.number = &H800708C5 Then
  3068.                 SetErrMsg L_ERR_PASSWORD_POLICY
  3069.             Else
  3070.                 SetErrMsg L_UNABLETOSET_PASSWORD_ERRORMESSAGE
  3071.             End If
  3072.             Exit Function
  3073.         End If
  3074.  
  3075.         'Release the object
  3076.         set objUser = nothing
  3077.         set objComputer = nothing
  3078.  
  3079.  
  3080.         SetPasswdInNT = TRUE
  3081.         Call SA_TRACEOUT("SetPasswdInNT","return success")
  3082.  
  3083.     End Function
  3084.  
  3085.  
  3086.     '---------------------------------------------------------------------
  3087.     ' Function name:    isFileExisting
  3088.     ' Description:        To verify the existence of the file
  3089.     ' Input Variables:    strFileToVerify-file name along with its path
  3090.     ' Output Variables:    None
  3091.     ' Return Values:    TRUE - if file exists , else FALSE
  3092.     ' Global Variables: None
  3093.     '---------------------------------------------------------------------
  3094.     Function isFileExisting(strFile)
  3095.         Err.Clear 
  3096.         On Error Resume Next
  3097.         
  3098.         Dim objFSO
  3099.         Set objFSO = CreateObject("Scripting.FileSystemObject")
  3100.         
  3101.         ' If the file is existing, return true, else false
  3102.         If objFSO.FileExists(strFile) Then
  3103.             isFileExisting = True                    
  3104.         Else
  3105.             isFileExisting = False
  3106.         End If
  3107.         
  3108.         Set objFSO = Nothing
  3109.     End Function
  3110.  
  3111.  
  3112.     '-------------------------------------------------------------------------
  3113.     'Function name        :LaunchProcess
  3114.     'Description        :Launches a new process 
  3115.     'Input Variables    :strCommand, strCurDir
  3116.     'Output Variables    :None
  3117.     'Returns            :Boolean
  3118.     '-------------------------------------------------------------------------
  3119.     Function LaunchProcess(strCommand, strCurDir)
  3120.         On error Resume Next
  3121.         Err.Clear 
  3122.         
  3123.         Dim objService        'holds WMI Connection
  3124.         Dim objClass        'holds query result
  3125.         Dim objProc            'holds query result of Win32_process
  3126.         Dim objProcStartup    'holds class spawninstance value
  3127.         Dim nretval            'holds return value
  3128.         Dim nPID            
  3129.         Dim objTemp            'holds temporary value
  3130.         
  3131.         nretval = 0
  3132.                 
  3133.         Set objService=getWMIConnection("root\cimv2")
  3134.         Set objClass = objService.Get("Win32_ProcessStartup")
  3135.         Set objProcStartup = objClass.SpawnInstance_()
  3136.         objProcStartup.ShowWindow = 2
  3137.         Set objProc = objService.Get("Win32_Process")
  3138.         nretval = objProc.Create(strCommand, strCurDir, objProcStartup,nPID)
  3139.         
  3140.         If Err.number <> 0  Then            
  3141.             Call SA_TraceOut(SA_GetScriptFileName(), "Function LaunchProcess failed, error: " & Hex(Err.Number) & " " & Err.Description)
  3142.             LaunchProcess = FALSE
  3143.             Exit function
  3144.         End If
  3145.         
  3146.         SA_TraceOut "inc_wsa", "Launch Process " & strCommand & " from path " & strCurDir & " successful "
  3147.             
  3148.         LaunchProcess = TRUE
  3149.         
  3150.         'Release objects
  3151.         Set objService= nothing
  3152.         Set objClass =  nothing
  3153.         Set objProcStartup = nothing
  3154.         Set objProc = nothing
  3155.     End Function
  3156.  
  3157.  
  3158.     '-------------------------------------------------------------------------
  3159.     '-------------------------------------------------------------------------
  3160.     '
  3161.     ' Functions to handle FrontPageServerExtension. 
  3162.     '
  3163.     ' 1) FPSE (2000, 2002) may be installed on the server (host). 
  3164.     ' 2) For IIS 6.0, FPSE may be enabled or diabled.
  3165.     ' 3) For each website, FPSE may be installed.    
  3166.     '
  3167.     ' The interfaces are:
  3168.     '
  3169.     ' 1) IsFrontPageInstalled (return true if any version installed)
  3170.     ' 2) IsFrontPageInstalledOnWebSite (return true if any version installed on the website)
  3171.     ' 3) InstallFrontPageWeb (install FPSE 2002 if found, otherwise install 2000)
  3172.     ' 4) UnInstallFrontPageWeb (uninstall the correct version of FPSE on the website)
  3173.     '    
  3174.     '-------------------------------------------------------------------------
  3175.     '-------------------------------------------------------------------------
  3176.  
  3177.  
  3178.     '-------------------------------------------------------------------------
  3179.     'Function name        :isFrontPageInstalled
  3180.     'Description        :Returns whether fron page extensions are installed on 
  3181.     '                    server or not
  3182.     'Input Variables    :None
  3183.     'Output Variables    :None
  3184.     'Returns            :Boolean
  3185.     'Global Variables    :None
  3186.     '-------------------------------------------------------------------------    
  3187.     Public Function isFrontPageInstalled(objService)
  3188.  
  3189.         '
  3190.         ' Check if FP 2000 is installed
  3191.         isFrontPageInstalled = isFrontPage2000Installed(objService)
  3192.  
  3193.         '
  3194.         ' If NOT then check if FP 2002 is installed
  3195.         If ( false = isFrontPageInstalled ) Then
  3196.             isFrontPageInstalled = isFrontPage2002Installed(objService)
  3197.         End If
  3198.  
  3199.     End Function
  3200.  
  3201.  
  3202.     '-------------------------------------------------------------------------
  3203.     'Function name        :isFrontPage2000Installed
  3204.     'Description        :Returns whether FPSE2000 are installed or not
  3205.     'Input Variables    :None
  3206.     'Output Variables    :None
  3207.     'Returns            :Boolean
  3208.     'Global Variables    :None
  3209.     '-------------------------------------------------------------------------    
  3210.     Private Function isFrontPage2000Installed(ByRef objService)
  3211.         On Error Resume Next
  3212.         Err.Clear 
  3213.  
  3214.         Dim objFrontPage    'holds frontpage query result
  3215.         
  3216.         isFrontPage2000Installed = false
  3217.  
  3218.         set objFrontPage = objService.Get("IIs_filter.Name=" & chr(34) & CONST_FRONTPAGE_PATH & chr(34))
  3219.  
  3220.         If Err.number <> 0 then
  3221.             SA_TraceOut "inc_wsa.asp", "Frontpage extensions not set. Error = " & Err.number
  3222.             exit function
  3223.         else
  3224.             if NOT IsObject(objFrontPage) then
  3225.                 exit function
  3226.             end if
  3227.             isFrontPage2000Installed = true
  3228.         end if
  3229.  
  3230.         'release the object
  3231.         set objFrontPage = nothing
  3232.     End Function
  3233.  
  3234.     '-------------------------------------------------------------------------
  3235.     'Function name        :isFrontPage2002Installed
  3236.     'Description        :Returns whether FPSE2002 are installed or not
  3237.     'Input Variables    :None
  3238.     'Output Variables    :None
  3239.     'Returns            :Boolean
  3240.     'Global Variables    :None
  3241.     '-------------------------------------------------------------------------    
  3242.     Private Function isFrontPage2002Installed(ByRef objService)
  3243.         on error resume next
  3244.  
  3245.         isFrontPage2002Installed = FALSE
  3246.         
  3247.         Dim aValues
  3248.         Dim x
  3249.         Dim objRegistry
  3250.  
  3251.         Set objRegistry = RegConnection()
  3252.         If (NOT IsObject(objRegistry)) Then
  3253.             Call SA_TraceOut(SA_GetScriptFileName(), "RegConnection() failed in function isFrontPage2002Installed, error: " & Hex(Err.Number) & " " & Err.Description )
  3254.             Exit Function
  3255.         End If
  3256.  
  3257.         
  3258.         '
  3259.         ' Search for FP Server Extensions 2002 installed reg key
  3260.         aValues =  RegEnumKey( objRegistry, "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\5.0")
  3261.         If ( IsNull(aValues) ) Then
  3262.             Exit Function
  3263.         End If
  3264.         'Call SA_TraceOut(SA_GetScriptFileName(), "RegEnumKey: " & "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\5.0")
  3265.         for x = LBound(aValues) to UBound(aValues)
  3266.             If ( IsNull(aValues(x)) ) Then
  3267.                 Exit Function
  3268.             End If
  3269.             'Call SA_TraceOut(SA_GetScriptFileName(), "RegKeyValue: " & aValues(x))
  3270.             If ( Trim(aValues(x)) = Trim(CONST_FRONTPAGE_2002_INSTALLED) ) Then            
  3271.                 isFrontPage2002Installed = true
  3272.                 exit for
  3273.             End If
  3274.         Next
  3275.  
  3276.         '
  3277.         ' Search for SharePoint installed reg key
  3278.         aValues =  RegEnumKeyValues( objRegistry, "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\5.0")
  3279.         If ( IsNull(aValues) ) Then
  3280.             Exit Function
  3281.         End If
  3282.         'Call SA_TraceOut(SA_GetScriptFileName(), "RegEnumKeyValues for: " & "SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\5.0")
  3283.         for x = LBound(aValues) to UBound(aValues)
  3284.             If ( IsNull(aValues(x)) ) Then
  3285.                 Exit Function
  3286.             End If
  3287.             'Call SA_TraceOut(SA_GetScriptFileName(), "RegKeyValue: " & aValues(x))
  3288.             If ( Trim(aValues(x)) = Trim(CONST_SHAREPOINT_INSTALLED) ) Then            
  3289.                 isFrontPage2002Installed = true
  3290.                 exit for
  3291.             End If
  3292.         Next
  3293.  
  3294.         Set objRegistry = nothing
  3295.     
  3296.     End Function
  3297.  
  3298.  
  3299.     '-------------------------------------------------------------------------
  3300.     'Function name        :InstallFrontPageWeb
  3301.     'Description        :Installs Front Page Extensions on the machine
  3302.     'Input Variables    :None
  3303.     'Output Variables    :None
  3304.     'Returns            :Boolean
  3305.     '-------------------------------------------------------------------------
  3306.     Function InstallFrontPageWeb(strSiteName, strUserName)
  3307.         On Error Resume Next
  3308.         Err.Clear 
  3309.                 
  3310.         Dim objRegConn                'holds regeconnection
  3311.         Dim strLocationFPSE2000        'holds location of string in registry
  3312.         Dim strLocationFPSE2002        'holds location of the FPSE 2002 location
  3313.         Dim strCommand                'holds string 
  3314.         Dim retval                    'holds return value
  3315.         
  3316.         InstallFrontPageWeb = FALSE
  3317.         
  3318.         Set objRegConn = RegConnection()
  3319.  
  3320.         if isFrontPage2002Installed Then
  3321.         
  3322.             strLocationFPSE2002 = GetRegKeyValue(objRegConn,CONST_FRONTPAGE_2002_REGLOC,"Location",CONST_STRING)
  3323.  
  3324.             strLocationFPSE2002 = strLocationFPSE2002 & "\" & "bin"
  3325.                 
  3326.             'SA_TraceOut "inc_wsa", "strLocationFPSE2002: " & strLocationFPSE2002            
  3327.             
  3328.             strCommand = "cmd.exe /c " & chr(34) & "owsadm.exe -o install -p /LM/" & strSiteName & " -type msiis -u " & strUserName & chr(34)
  3329.  
  3330.             'SA_TraceOut "inc_wsa", "strCommandFPSE2002: " & strCommand
  3331.  
  3332.             InstallFrontPageWeb = LaunchProcess(strCommand, strLocationFPSE2002)
  3333.         
  3334.         ElseIf isFrontPage2000Installed Then
  3335.         
  3336.             strLocationFPSE2000 = GetRegKeyValue(objRegConn,CONST_FRONTPAGE_REGLOC,"Location",CONST_STRING)
  3337.  
  3338.             strLocationFPSE2000 = strLocationFPSE2000 & "\" & "bin"
  3339.  
  3340.             'SA_TraceOut "inc_wsa", "strLocationFPSE2000: " & strLocationFPSE2000
  3341.  
  3342.             strCommand = "cmd.exe /c " & chr(34) & "fpsrvadm.exe -o install -p /LM/" & strSiteName & " -type msiis -u " & strUserName & chr(34)
  3343.  
  3344.             'SA_TraceOut "inc_wsa", "strCommandFPSE2000: " & strCommand
  3345.  
  3346.             InstallFrontPageWeb = LaunchProcess(strCommand, strLocationFPSE2000)
  3347.         
  3348.         Else
  3349.         
  3350.             call SA_TraceOut("inc_wsa", "Function InstallFrontPageWeb: Frontpage Extension not Installed on the server")
  3351.             
  3352.         End If
  3353.             
  3354.         'Release objects
  3355.         Set objRegConn = nothing                
  3356.  
  3357.     End Function
  3358.  
  3359.     '-------------------------------------------------------------------------
  3360.     'Function name        :UnInstallFrontPageWeb
  3361.     'Description        :UnInstalls Front Page Extensions on the machine
  3362.     'Input Variables    :None
  3363.     'Output Variables    :None
  3364.     'Returns            :Boolean
  3365.     '-------------------------------------------------------------------------
  3366.     Function UnInstallFrontPageWeb(strSiteName)
  3367.         On Error Resume Next
  3368.         Err.Clear
  3369.                         
  3370.         Dim objRegConn                'holds regeconnection
  3371.         Dim strLocationFPSE2000        'holds location of string in registry
  3372.         Dim strLocationFPSE2002        'holds location of the FPSE 2002 location
  3373.         Dim strCommand                'holds string 
  3374.         Dim retval                    'holds return value
  3375.  
  3376.         UnInstallFrontPageWeb = FALSE
  3377.         
  3378.         Set objRegConn = RegConnection()
  3379.  
  3380.         if IsFrontPage2002InstalledOnWebSite(strSiteName) Then
  3381.  
  3382.             strLocationFPSE2002 = GetRegKeyValue(objRegConn,CONST_FRONTPAGE_2002_REGLOC,"Location",CONST_STRING)
  3383.     
  3384.             strLocationFPSE2002 = strLocationFPSE2002 & "\" & "bin"
  3385.                 
  3386.             'SA_TraceOut "inc_wsa", "strLocationFPSE2002: " & strLocationFPSE2002            
  3387.  
  3388.             strCommand = "cmd.exe /c " & chr(34) & "owsadm.exe -o uninstall -p /LM/" & strSiteName & chr(34)
  3389.  
  3390.             'Call SA_TraceOut("inc_wsa", "Function UnInstallFrontPageWeb: FPSE 2002 command: " & strCommand)
  3391.  
  3392.             UnInstallFrontPageWeb = LaunchProcess(strCommand, strLocationFPSE2002)
  3393.         
  3394.         ElseIf IsFrontPage2000InstalledOnWebSite(strSiteName) Then
  3395.  
  3396.             strLocationFPSE2000 = GetRegKeyValue(objRegConn,CONST_FRONTPAGE_REGLOC,"Location",CONST_STRING)
  3397.  
  3398.             strLocationFPSE2000 = strLocationFPSE2000 & "\" & "bin"
  3399.  
  3400.             'SA_TraceOut "inc_wsa", "strLocationFPSE2000: " & strLocationFPSE2000
  3401.  
  3402.             strCommand = "cmd.exe /c " & chr(34) & "fpsrvadm.exe -o uninstall -p /LM/" & strSiteName & chr(34)
  3403.  
  3404.             'Call SA_TraceOut("inc_wsa", "Function UnInstallFrontPageWeb: FPSE 2000 command: " & strCommand)
  3405.  
  3406.             UnInstallFrontPageWeb = LaunchProcess(strCommand, strLocationFPSE2000)
  3407.         
  3408.         Else
  3409.         
  3410.             call SA_TraceOut("inc_wsa", "Function UnInstallFrontPageWeb: Frontpage Extension not installed on the server")
  3411.             
  3412.         End If
  3413.                 
  3414.         'Release objects
  3415.         Set objRegConn = nothing
  3416.         
  3417.     End Function
  3418.  
  3419.  
  3420.     
  3421.     '-------------------------------------------------------------------------
  3422.     'Function name        :IsFrontPageInstalledOnWebSite
  3423.     'Description        :Determines whether front page extensions are installed 
  3424.     '                    on that web site
  3425.     'Input Variables    :strSysName, strSiteName
  3426.     'Output Variables    :None
  3427.     'Returns            :Boolean
  3428.     '-------------------------------------------------------------------------
  3429.     Function IsFrontPageInstalledOnWebSite(strSysName, strSiteName)
  3430.         On Error Resume Next
  3431.         Err.Clear 
  3432.         
  3433.         'Dim objSite        'holds IIS root object
  3434.     
  3435.         IsFrontPageInstalledOnWebSite = false
  3436.         
  3437.         If IsFrontPage2000InstalledOnWebSite( strSiteName) or IsFrontPage2002InstalledOnWebSite( strSiteName) Then                    
  3438.             
  3439.             IsFrontPageInstalledOnWebSite = true
  3440.             
  3441.         End If
  3442.         
  3443.         'Set objSite = GetObject("IIS:")
  3444.         'Set objSite = objSite.OpenDSObject("IIS://" & strSysName & "/" & strSiteName, "", "", 1)
  3445.         'if Err.number <> 0 then
  3446.         '    Err.Clear
  3447.         '    SA_TraceOut "inc_wsa", "Failed to determine whether front page extensions are installed for site: " & strSiteName
  3448.         '    Exit function
  3449.         'end if
  3450.         'IsFrontPageInstalledOnWebSite = objSite.FrontPageWeb
  3451.         
  3452.         'Release the objects
  3453.         'set objSite = nothing
  3454.     End Function
  3455.  
  3456.  
  3457.  
  3458.     '-------------------------------------------------------------------------
  3459.     'Function name        :IsFrontPage2000InstalledOnWebSite
  3460.     'Description        :Determines whether front page extensions are installed 
  3461.     '                    on that web site
  3462.     'Input Variables    :strSysName, strSiteName
  3463.     'Output Variables    :None
  3464.     'Returns            :Boolean
  3465.     '-------------------------------------------------------------------------
  3466.     Function IsFrontPage2000InstalledOnWebSite( strSiteName)
  3467.         On Error Resume Next
  3468.         Err.Clear 
  3469.         
  3470.         Dim objRegConn          'registry connection
  3471.         Dim strSitePortLoc      'registry key location of the website 
  3472.         Dim strFrontPageRoot
  3473.         Dim strAuthoring
  3474.     
  3475.         IsFrontPage2000InstalledOnWebSite = false
  3476.         
  3477.         ' The registry key is the same for all OS versions
  3478.         strSitePortLoc = CONST_PORT_REGLOC & "Port /LM/" & strSiteName & ":"
  3479.         
  3480.         Set objRegConn = RegConnection()
  3481.  
  3482.         strAuthoring = GetRegKeyValue(objRegConn,strSitePortLoc,"authoring",CONST_STRING)
  3483.  
  3484.         strFrontPageRoot = GetRegKeyValue(objRegConn,strSitePortLoc,"frontpageroot",CONST_STRING)
  3485.             
  3486.         if Ucase(strAuthoring) = "ENABLED" and instr(strFrontPageRoot, "\40") Then
  3487.         
  3488.             IsFrontPage2000InstalledOnWebSite = true
  3489.     
  3490.         End If
  3491.     
  3492.         set objRegConn = nothing
  3493.         
  3494.     End Function
  3495.  
  3496.  
  3497.     '-------------------------------------------------------------------------
  3498.     'Function name        :IsFrontPage2002InstalledOnWebSite
  3499.     'Description        :Determines whether front page extensions are installed 
  3500.     '                    on that web site
  3501.     'Input Variables    :strSysName, strSiteName
  3502.     'Output Variables    :None
  3503.     'Returns            :Boolean
  3504.     '-------------------------------------------------------------------------
  3505.     Function IsFrontPage2002InstalledOnWebSite( strSiteName)
  3506.         On Error Resume Next
  3507.         Err.Clear 
  3508.         
  3509.         Dim objRegConn          'registry connection
  3510.         Dim strSitePortLoc      'registry key location of the website 
  3511.         Dim strFrontPageRoot
  3512.         Dim strAuthoring
  3513.     
  3514.         IsFrontPage2002InstalledOnWebSite = false
  3515.         
  3516.         ' The registry key is the same for all OS versions
  3517.         strSitePortLoc = CONST_PORT_REGLOC & "Port /LM/" & strSiteName & ":"
  3518.         
  3519.         Set objRegConn = RegConnection()
  3520.  
  3521.         strAuthoring = GetRegKeyValue(objRegConn,strSitePortLoc,"authoring",CONST_STRING)
  3522.         
  3523.         strFrontPageRoot = GetRegKeyValue(objRegConn,strSitePortLoc,"frontpageroot",CONST_STRING)
  3524.             
  3525.         if Ucase(strAuthoring) = "ENABLED" and instr(strFrontPageRoot, "\50") Then
  3526.         
  3527.             IsFrontPage2002InstalledOnWebSite = true
  3528.     
  3529.         End If
  3530.     
  3531.         set objRegConn = nothing
  3532.         
  3533.     End Function
  3534.  
  3535.     '-------------------------------------------------------------------------
  3536.     '-------------------------------------------------------------------------
  3537.     '
  3538.     ' Functions to handle FTP
  3539.     '
  3540.     '
  3541.     '    
  3542.     '-------------------------------------------------------------------------
  3543.     '-------------------------------------------------------------------------
  3544.  
  3545.     '-------------------------------------------------------------------------
  3546.     'Function name:            IsFTPEnabled
  3547.     'Description:            Initialization of global variables is done
  3548.     'Input Variables:        None
  3549.     'Returns:                true/false
  3550.     'Global Variables:        G_objService
  3551.     '                        G_objSites
  3552.     '--------------------------------------------------------------------------
  3553.     
  3554.     Function IsFTPEnabled()
  3555.         Err.Clear
  3556.         on error resume next
  3557.         
  3558.         Dim objFTP
  3559.         Dim objFTPList
  3560.         Dim objService
  3561.         
  3562.         IsFTPEnabled = false
  3563.         
  3564.         ' Get instances of IIS_FTPServiceSetting that are visible throughout
  3565.         Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  3566.         set objFTPList = objService.InstancesOf(GetIISWMIProviderClassName("IIS_FTPService"))
  3567.  
  3568.         For each objFTP in objFTPList
  3569.             if objFTP.State = CONST_SERVICE_RUNNING_STATE Then        
  3570.                 IsFTPEnabled = true            
  3571.             End If
  3572.         Next 
  3573.  
  3574.         if Err.number <> 0 then    
  3575.             IsFTPEnabled = false
  3576.             Err.Clear
  3577.         end if
  3578.         
  3579.         set objtFTPList = nothing
  3580.         set objFTP = nothing
  3581.         set objService = nothing
  3582.         
  3583.     end function
  3584.         
  3585.     
  3586.     '-------------------------------------------------------------------------
  3587.     'Function name:            EnableFTP
  3588.     'Description:            Enable FTP service and set it's state to automatic
  3589.     'Input Variables:        None
  3590.     'Returns:                None
  3591.     'Global Variables:        
  3592.     '--------------------------------------------------------------------------    
  3593.     Function EnableFTP()
  3594.         Err.Clear
  3595.         on error resume next
  3596.         
  3597.         Dim objFTP        
  3598.         Dim objService
  3599.         
  3600.         EnableFTP = false
  3601.                 
  3602.         ' Get instances of IIS_FTPServiceSetting that are visible throughout
  3603.         Set objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)            
  3604.         set objFTP = objService.get("Win32_Service.Name='MSFTPSVC'")
  3605.                        
  3606.         Call objFTP.ChangeStartMode("Automatic")
  3607.         Call objFTP.StartService()     
  3608.         EnableFTP = true                           
  3609.  
  3610.         if Err.number <> 0 then    
  3611.             EnableFTP = false
  3612.             Err.Clear
  3613.         end if
  3614.                 
  3615.         set objFTP = nothing
  3616.         set objService = nothing
  3617.         
  3618.     end function
  3619.     
  3620.     
  3621.     
  3622.     '-------------------------------------------------------------------------
  3623.     'Function name:            DisableFTP
  3624.     'Description:            Diable FTP service and set it's state to manual
  3625.     'Input Variables:        None
  3626.     'Returns:                None
  3627.     'Global Variables:        
  3628.     '--------------------------------------------------------------------------    
  3629.     Function DisableFTP()
  3630.         Err.Clear
  3631.         on error resume next
  3632.         
  3633.         Dim objFTP        
  3634.         Dim objService
  3635.         
  3636.         DisableFTP = false
  3637.                 
  3638.         ' Get instances of IIS_FTPServiceSetting that are visible throughout
  3639.         Set objService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)            
  3640.         set objFTP = objService.get("Win32_Service.Name='MSFTPSVC'")
  3641.                        
  3642.         Call objFTP.ChangeStartMode("Manual")
  3643.         Call objFTP.StopService()     
  3644.         DisableFTP = true                           
  3645.  
  3646.         if Err.number <> 0 then    
  3647.             DisableFTP = false
  3648.             Err.Clear
  3649.         end if
  3650.                 
  3651.         set objFTP = nothing
  3652.         set objService = nothing
  3653.         
  3654.     end function
  3655.     '-------------------------------------------------------------------------
  3656.     'Function name:            SetFPSEOption
  3657.     'Description:            Set FPSE Option in the registry 
  3658.     'Input Variables:        
  3659.     'Returns:                None
  3660.     'Global Variables:        
  3661.     '--------------------------------------------------------------------------    
  3662.     Function SetFPSEOption(bEnableFPSE)
  3663.     
  3664.         dim objRegConn
  3665.         dim iFPSEOption
  3666.         Set objRegConn = RegConnection()
  3667.         
  3668.         'Init the value to be set to the regval
  3669.         if bEnableFPSE Then
  3670.             iFPSEOption = 1
  3671.         Else
  3672.             iFPSEOption = 0
  3673.         End If
  3674.         
  3675.         call updateRegkeyvalue(objRegConn,CONST_WEBBLADES_REGKEY,CONST_FPSEOPTION_REGVAL,iFPSEOption,CONST_DWORD)
  3676.  
  3677.         If Err.number <> 0 Then
  3678.             SA_TraceOut "inc_wsa", "Set regvalue for FPSEOption failed " & Hex(Err.Number)
  3679.             exit Function
  3680.         End if
  3681.         
  3682.     End Function
  3683.  
  3684.  
  3685.     '-------------------------------------------------------------------------
  3686.     'Function name:            GetFPSEOption
  3687.     'Description:            Get FPSE Option in the registry. If the regval is 1, it means
  3688.     '                        PFSE is enabled by default for all Website created thru WebUI,
  3689.     '                        and GetFPSEOption return true. Otherwise return false.
  3690.     'Input Variables:        
  3691.     'Returns:                True if PFSE is enabled by default for all Website created thru WebUI
  3692.     'Global Variables:        
  3693.     '--------------------------------------------------------------------------    
  3694.     Function GetFPSEOption()
  3695.  
  3696.         dim objRegConn
  3697.         dim iFPSEOption
  3698.         
  3699.         GetFPSEOption = false
  3700.         
  3701.         Set objRegConn = RegConnection()
  3702.  
  3703.         iFPSEOption = GetRegKeyValue(objRegConn,CONST_WEBBLADES_REGKEY,CONST_FPSEOPTION_REGVAL,CONST_DWORD)
  3704.         
  3705.         If Err.number <> 0 Then
  3706.             SA_TraceOut "inc_wsa", "Get regvalue for FPSEOption failed " & Hex(Err.Number)
  3707.             exit Function
  3708.         End if
  3709.  
  3710.         if iFPSEOption = 1 then
  3711.             GetFPSEOption = true
  3712.         End If
  3713.             
  3714.     End Function
  3715.  
  3716.     '-------------------------------------------------------------------------
  3717.     '-------------------------------------------------------------------------
  3718.     '
  3719.     ' Functions to handle ASP enable/disable
  3720.     '
  3721.     '
  3722.     '    
  3723.     '-------------------------------------------------------------------------
  3724.     '-------------------------------------------------------------------------
  3725.     
  3726.     '-------------------------------------------------------------------------
  3727.     'Function name:            IsASPEnabled
  3728.     'Description:            Check if ASP is enable at the webroot (for all website)
  3729.     'Input Variables:        None
  3730.     'Returns:                None
  3731.     'Global Variables:        
  3732.     '--------------------------------------------------------------------------    
  3733.     Function IsASPEnabled()
  3734.         Err.Clear
  3735.         on error resume next        
  3736.         IsASPEnabled = false
  3737.         
  3738.     end function
  3739.     
  3740.     
  3741.     '-------------------------------------------------------------------------
  3742.     'Function name:            EnableASP
  3743.     'Description:            Enable ASP for all the website (at the webroot)
  3744.     'Input Variables:        None
  3745.     'Returns:                None
  3746.     'Global Variables:        
  3747.     '--------------------------------------------------------------------------    
  3748.     Function EnableASP()
  3749.         Err.Clear
  3750.         on error resume next
  3751.     end function
  3752.     
  3753.     '-------------------------------------------------------------------------
  3754.     'Function name:            DisableASP
  3755.     'Description:            Diable ASP at the webroot (except Administration site)
  3756.     'Input Variables:        None
  3757.     'Returns:                None
  3758.     'Global Variables:        
  3759.     '--------------------------------------------------------------------------    
  3760.     Function DisableASP()
  3761.         Err.Clear
  3762.         on error resume next
  3763.     end function
  3764.     
  3765.     
  3766.  
  3767.  
  3768.     '-------------------------------------------------------------------------
  3769.     '-------------------------------------------------------------------------
  3770.     '
  3771.     ' Helper functions for common UI between site.new and site.modify
  3772.     '
  3773.     '
  3774.     '    
  3775.     '-------------------------------------------------------------------------
  3776.     '-------------------------------------------------------------------------
  3777.     
  3778.     '-------------------------------------------------------------------------
  3779.     'Function name:         IsFTPAllowedOnSite
  3780.     'Description:        Determines whether we should allow an FTP virtual
  3781.     '                       directory to be created for this site based on
  3782.     '                       the ACLs on the root directory for the site.  If
  3783.     '                       interactive users are allowed access, we
  3784.     '                       deem the site unsafe for FTP access and disable
  3785.     '                       the option.
  3786.     'Input Variables:    strPath             Local path of root directory
  3787.     '                                           for this site.
  3788.     'Returns:        True if FTP access should be allowed and False
  3789.     '                       otherwise.
  3790.     'Global Variables:    None
  3791.     '--------------------------------------------------------------------------    
  3792.     Function IsFTPAllowedOnSite(strPath)
  3793.         On Error Resume Next
  3794.         IsFTPAllowedOnSite = True
  3795.         
  3796.         '
  3797.         ' Get the WMI path to the security settings for the web root.
  3798.         '        
  3799.         Dim strFolderSecurityPath
  3800.         strFolderSecurityPath = "Win32_LogicalFileSecuritySetting.Path=""" & strPath & """"
  3801.         
  3802.         ' Replace single backslashes with double backslashes.
  3803.         Dim oRegExp
  3804.         Set oRegExp = New RegExp
  3805.         oRegExp.Pattern = "\\"
  3806.         oRegExp.Global = true
  3807.         strFolderSecurityPath = oRegExp.Replace(strFolderSecurityPath, "\\")
  3808.         
  3809.         
  3810.         '
  3811.         ' Open the object for the web root directory.  If the directory doesn't
  3812.         ' exist, assume this is a new site.
  3813.         '
  3814.         Dim oService
  3815.         Set oService = getWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  3816.         
  3817.         Dim oFolderSecurity
  3818.         Set oFolderSecurity = oService.Get(strFolderSecurityPath)
  3819.         
  3820.         If (wbemErrNotFound = Err.number) Then
  3821.             ' The directory doesn't exist, so allow FTP
  3822.             IsFTPAllowedOnSite = True
  3823.             Exit Function
  3824.         End If
  3825.  
  3826.         Dim oSecurityDescriptor
  3827.         If (0 = oFolderSecurity.GetSecurityDescriptor(oSecurityDescriptor)) Then
  3828.             Dim oACE
  3829.             For Each oACE In oSecurityDescriptor.DACL
  3830.                 Dim oTrustee
  3831.                 Set oTrustee = oACE.Trustee
  3832.                 If ((SIDSTRING_INTERACTIVE = oTrustee.SIDString) And _
  3833.                     (0 <> oACE.AccessMask)) Then
  3834.                     '
  3835.                     ' Interactive users have access, which suggests that
  3836.                     ' FPSE have been installed on this site before.  Even if
  3837.                     ' FPSE haven't been installed, this site is not secure
  3838.                     ' enough to allow FTP access.
  3839.                     IsFTPAllowedOnSite = False
  3840.                 End If
  3841.             Next
  3842.         End If
  3843.         
  3844.         If (Err.number <> 0) Then
  3845.             ' This should never happen, but fail securely if it does.
  3846.             IsFTPAllowedOnSite = False
  3847.         End If
  3848.     End Function
  3849.  
  3850.     '-------------------------------------------------------------------------
  3851.     'Sub name:              ServeAppSettings
  3852.     'Description:            Serves common UI between site new and site modify
  3853.     '                       pages on application settings tabs.  Currently
  3854.     '                       displays only settings below default page values.
  3855.     '                       Should be expanded in the future to include all UI
  3856.     '                       for this tab.
  3857.     'Input Variables:        strPath             Local path of root directory
  3858.     '                                           for this site.
  3859.     '                       strUploadMethod     The method currently used to
  3860.     '                                           upload content to this site.
  3861.     '                                           See constants defined above
  3862.     '                                           for valid values (e.g.,
  3863.     '                                           UPLOADMETHOD_NEITHER)
  3864.     '                       strAnonymousChecked The value passed in the form
  3865.     '                                           submission for the anonymous
  3866.     '                                           checkbox (e.g., "true").
  3867.     'Returns:                None
  3868.     'Global Variables:        Localized strings from resources.asp
  3869.     '--------------------------------------------------------------------------    
  3870.     Sub ServeAppSettings(strPath, strUploadMethod, strAnonymousChecked, bNewSite)
  3871.         On Error Resume Next
  3872.  
  3873.         '
  3874.         ' Calculate the attributes of the radio buttons and checkbox based on
  3875.         ' the current settings on the site.
  3876.         '
  3877.         Dim oIISService        
  3878.         Set oIISService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)        
  3879.  
  3880.         Dim strNeitherAttributes
  3881.         strNeitherAttributes = "CHECKED"
  3882.  
  3883.         Dim strFPSEAttributes
  3884.         Dim strFTPAttributes
  3885.  
  3886.         ' Check FrontPage extensions
  3887.         If (isFrontPageInstalled(oIISService)) Then
  3888.             If (strUploadMethod = UPLOADMETHOD_FPSE) Then
  3889.                 strFPSEAttributes = "CHECKED"
  3890.                 strNeitherAttributes = ""
  3891.             Else
  3892.                 strFPSEAttributes = ""
  3893.             End If
  3894.         Else
  3895.             strFPSEAttributes = "DISABLED"
  3896.         End If
  3897.         
  3898.         ' Check FTP
  3899.         If ((Not IsFTPEnabled()) Or (Not IsAdminFTPServerExistAndRunning())) Then
  3900.             strFTPAttributes = "DISABLED"
  3901.         ElseIf (Not IsFTPAllowedOnSite(strPath)) Then
  3902.             If (strUploadMethod = UPLOADMETHOD_FTP) Then
  3903.                 strFTPAttributes = "CHECKED DISABLED"
  3904.                 strNeitherAttributes = ""
  3905.             Else
  3906.                 strFTPAttributes = "DISABLED"
  3907.             End If
  3908.         Else
  3909.             If (strUploadMethod = UPLOADMETHOD_FTP) Then
  3910.                 strFTPAttributes = "CHECKED"
  3911.                 strNeitherAttributes = ""
  3912.             Else
  3913.                 strFTPAttributes = ""
  3914.             End If
  3915.         End If
  3916.         
  3917.         ' Check anonymous access
  3918.         Dim strAnonymousAttributes
  3919.         If ("true" = strAnonymousChecked) Then
  3920.             strAnonymousAttributes = "CHECKED"
  3921.         Else
  3922.             strAnonymousAttributes = ""
  3923.         End If
  3924.         
  3925.         '
  3926.         ' Output the UI based on the settings processed above.
  3927.         '
  3928.         
  3929.         '
  3930.         ' Note: FrontPage messages not HTML encoded to allow ® to be
  3931.         ' displayed correctly.
  3932.         '
  3933. %>
  3934.                 <TABLE WIDTH="400" ALIGN="left" BORDER="0" CELLSPACING="0" CELLPADDING="0"
  3935.                        CLASS="TasksBody">
  3936.                     <TR>
  3937.                         <TD CLASS="TasksBody" COLSPAN="3" NOWRAP>
  3938.                             <%=Server.HTMLEncode(L_CONTENT_UPLOADMETHOD_TITLE)%>
  3939.                         </TD>
  3940.                     </TR>
  3941.                     <TR>
  3942.                         <TD CLASS="TasksBody" WIDTH="15px"> </TD>
  3943.                         <TD CLASS="TasksBody">
  3944.                             <INPUT TYPE="radio" CLASS="FormRadioButton" NAME="radUploadMethod"
  3945.                                    VALUE="<%=UPLOADMETHOD_FPSE%>" <%=strFPSEAttributes%>>
  3946.                         </TD>
  3947.                         <TD CLASS="TasksBody" NOWRAP>
  3948.                             <%=L_APPL_FRONT_PAGE_EXTN_TEXT%>
  3949.                         </TD>
  3950.                     </TR>
  3951.                     <TR>
  3952.                         <TD CLASS="TasksBody" COLSPAN="2"> </TD>
  3953.                         <TD CLASS="TasksBody">
  3954.                             <%=Server.HTMLEncode(L_FRONTPAGEFTP_WARNING_TEXT)%>
  3955.                         </TD>
  3956.                     </TR>
  3957.                     <TR>
  3958.                         <TD CLASS="TasksBody" WIDTH="15px"> </TD>
  3959.                         <TD CLASS="TasksBody">
  3960.                             <INPUT TYPE="radio" CLASS="FormRadioButton" NAME="radUploadMethod"
  3961.                                    VALUE="<%=UPLOADMETHOD_FTP%>" <%=strFTPAttributes%>>
  3962.                         <TD CLASS="TasksBody" NOWRAP>
  3963.                             <%=Server.HTMLEncode(L_CREATE_FTP_SITE)%>
  3964.                         </TD>
  3965.                     </TR>
  3966.                     <TR>        
  3967.                         <TD CLASS="TasksBody" WIDTH="15px"> </TD>
  3968.                         <TD CLASS="TasksBody">
  3969.                             <INPUT TYPE="radio" CLASS="FormRadioButton" NAME="radUploadMethod"
  3970.                                    VALUE="<%=UPLOADMETHOD_NEITHER%>" <%=strNeitherAttributes%> ID="Radio1">
  3971.                         </TD>
  3972.                         <TD CLASS="TasksBody" NOWRAP>
  3973.                             <%=Server.HTMLEncode(L_CONTENT_UPLOADMETHOD_NEITHER)%>
  3974.                         </TD>
  3975.                     </TR>
  3976.                     <TR><TD CLASS="TasksBody" COLSPAN="3"> </TD></TR>
  3977.                     <TR>
  3978.                         <TD CLASS="TasksBody" COLSPAN="3" NOWRAP>
  3979.                             <INPUT TYPE="checkbox" CLASS="formField" NAME="chkAllow" VALUE="ON"
  3980.                                    <%=strAnonymousAttributes%>>
  3981.                             <%=Server.HTMLEncode(L_ALLOW_ANONYMOUS_ACCESS)%>
  3982.                         </TD>
  3983.                     </TR>        
  3984.                 </TABLE>
  3985. <%
  3986.     End Sub
  3987. %>
  3988.